Posts tagged php
Recently I’ve had this really nagging issue where I could no longer send email from Roundcube. Mail would send just fine from any email client. A review of the mail logs for the failed message being sent from Roundcube gave a puzzling error about an unbalanced “< ” proceeding the recipient’s name with the email address. I did find that removing the person’s name proceeding the email address from the “To” line allowed me to send the message. Basically, removing the name when the field looks like this:
John Doe <email@example.com>
I tried playing around with a few things including re-installations of Roundcube and did a really thorough glean of my sendmail config files comparing them to the defaults. Looking through the MySQL database showed no extra angle brackets in any of the stored contacts. I did find a post on the Roundcube forums about the same error but for an older version. I tried messing around with some of the PHP files as the fix mentioned in the article was no longer applicable due to filename changes, but had no change in behavior. Thinking that perhaps there was some bug in the PHP code itself I tried installing later versions but I still got the same error about the message failing to send. I had no issues with the 0.3.x releases. This issue cropped up in the 0.5.x branch.
Finally on a hunch I began to suspect that mini_sendmail-chroot was the culprit. It turns out that I was exactly right. A search of the OpenBSD mailing list archives pointed me to a replacement called femail-chroot which was described as being less problematic. I tried it out and problem resolved! I’m not sure what it was about mini_sendmail that breaks with newer PHP scripts. Unfortunately, the project is apparently no longer maintained with the last release being from 2005.
Femail is basically a drop-in replacement for mini_sendmail. The only work involved is to just point PHP to it in your php.ini and restart Apache. You can install femail-chroot as a package (run pkg_add femail-chroot as root) or from ports (mail/femail). If you install it from ports please note that the chrooted version is available as a flavor.
I’ve finally hopped on the bandwagon. I’ve tried several different types of web based email clients while working for a web hosting company (most free/open source and some proprietary) and all of them were horrid with SquirrelMail being the best of the worst. SquirrelMail is a very simple IMAP client that is mostly frame-based with some pretty nice plugins. While uncluttered and pretty fast it doesn’t have the elegance of some of the large email providers’ interfaces such as Gmail.
Not too long ago a fellow OpenBSD user recommended Round Cube to me on Twitter. At first I was a bit lazy to install it and now I realize the error of my ways. You’re probably wondering so far what the heck Round Cube has to do with OpenBSD since this is a site dedicated to it. That’s actually the nice part since Round Cube is available both as a package (roundcubemail) and is in the Ports tree (mail/roundcubemail). As of OpenBSD 4.7 the latest supported release is 0.3.1p1. It appears that 0.4.2 might be in -current/4.8 as OpenPorts.se has it listed as a download.
Round Cube has a very clean interface and is fairly reminiscent of most desktop email clients and Apple’s MobileMe web client. It supports folders, address books, and more. The address book feature even supports the import of vCards.
The installation was somewhat complicated at first. The application itself is PHP based but uses MySQL, PostgreSQL, or SQLite to store user settings. The INSTALL file placed in /var/www/roundcubemail is pretty straightforward but incomplete in a couple places. I went with the MySQL installation for the database backend. Once you’ve created your database and roundcube user be sure that you then put the user’s password in the config/db.inc.php file on that line that looks like this where “pass” is the password:
$rcmail_config['db_dsnw'] = ‘mysql://roundcube:pass@localhost/roundcubemail’
You also need to enable the web installer in the config/main.inc.php by change the following line to “true”:
$rcmail_config['enable_installer'] = false;
There are also TLS and SSL options that you can turn on and probably will if you’ve read my previous posts on enabling these in Apache and sendmail.
The installer will run some checks to be sure that it can connect to your database and that you have the necessary PHP extensions installed and options enabled in php.ini. At the end it checks whether it can make an IMAP and SMTP connection.
So, check it out at http://roundcube.net/. The download link will first list the requirements as LAMP with a small link to the FreeBSD and OpenBSD versions. Be not afraid. You now know that Round Cube works on OAMP!
What’s PHP without mail? Well, it’s quite the pain to get working inside a chroot with Apache. After a week of searching online and trying out different things in php.ini I’ve found the answer.
First, it’s important to know that PHP can’t call the server’s copy of sendmail inside the chroot. Therefore, you’re going to need one that it can use. Luckily it’s available as a package or a port (mail/mini_sendmail). To install the package simply run:
Second, you need a copy of the Bourne shell for the chroot. Grab a copy like this:
cp /bin/sh /var/www/bin/sh
Lastly, we need to tell PHP where to find mini_sendmail. So, we are going to edit our php.ini in (/var/www/conf/php.ini) and change the sendmail_path line like this:
sendmail_path = “/bin/mini_sendmail -t -i”
Stop (if running) and start Apache:
apachectl stop; apachectl start
Have fun and use this for good, not spamming!