Page 1 of 1
Swiftmailer Operation
Posted: Wed May 23, 2007 3:43 pm
by chuckl
I'm looking at using Swiftmailer to replace PHPMailer in a php web application, where the app has a dropdown selection of email transports. One of these is the ubiquitous sendmail-f to try and get a real sender in there and get the mail past the spam filters.
I assume that as Swiftmailer uses a mandatory "-bs " approach that the 'emulation' of the -f flag should be handled by the set methods rather than attempting to tack it on the end of the sendmail string?
Second one relates to the host environment. When I test on my Ubuntu/Postfix server, all is rosy and I can switch between the available transports at will. SMTP Gmail doesn't work, but that's a separate security issue, nothing to do with any Swiftmailer deficits.
However, when I switch to a hosted environment with a RH ELsmp/Exim setup, it crashes and burns on sendmail, essentially unable to find the sendmail binary with stat() error/exception. I've tried AUTO_DETECT, no path, all the options, no luck.
If however, I drop in PHPMailer, (I have it set up as a 1 file rename), all is sweetness and light, and it sends perfectly. Or rather it sends, as the envelope sender is nailed on the dreaded Apache 'nobody' and nothing I do seems to make any difference to that.
Anyone have any thoughts/experience on this?
Rgds,
Posted: Thu May 24, 2007 12:53 am
by Chris Corbyn
Does the RH server run PhpSuExec?
Posted: Thu May 24, 2007 2:54 am
by chuckl
No idea, I had access to the thing briefly as I was helping sort out another issue, and permission to do a quick Mailer test. I doubt it though, as it's running everything as 'nobody', which I wouldn't expect with phpSuExec.
Posted: Thu May 24, 2007 5:56 am
by Chris Corbyn
chuckl wrote:No idea, I had access to the thing briefly as I was helping sort out another issue, and permission to do a quick Mailer test. I doubt it though, as it's running everything as 'nobody', which I wouldn't expect with phpSuExec.
I'm not sure how PhpSuExec varies from apache SuExec. I was just trying to figure out why a basic call to stat() would fail if the file really is there and can be executed.
You're right in your assumption that PHPMailer uses -t mode whereas Swift uses -bs mode. You get some feedback in -bs mode since it's SMTP. There is some 'experimental' -t mode code in Swift, but it's not supported and I haven't actually touched that code for a while so it probably won't work at all right now.
Posted: Thu May 24, 2007 8:18 am
by chuckl
I agree, about the wierdness, I'll see if I can scrounge some more time on the system to test - people love you 'just quickly' doing things on their live systems...
Again, I don't know much about Exim, never use it. Does it have a strange path or anything that you know of?
Your comments on whether my assumptions about emulating the -f by setting the header values would be appreciated as well.
Rgds,
Posted: Thu May 24, 2007 8:34 am
by chuckl
I should probably mention that if I set the transport to php - i.e. native mail, the mail goes out, but by the time it's been through the mill of a couple of mailservers, all HTML has been stripped, it's 7bit ascii etc etc.
Posted: Thu May 24, 2007 8:41 am
by Chris Corbyn
chuckl wrote:I agree, about the wierdness, I'll see if I can scrounge some more time on the system to test - people love you 'just quickly' doing things on their live systems...
Again, I don't know much about Exim, never use it. Does it have a strange path or anything that you know of?
Your comments on whether my assumptions about emulating the -f by setting the header values would be appreciated as well.
Rgds,
Sussed it. Symbolic links are not followed with stat(). They'll be a simple fix for this
EDIT | Indeed, changing stat() to lstat() is the fix.
Posted: Thu May 24, 2007 9:15 am
by chuckl
Sounds very feasible to me.
I'll implement these vast edits and see if I can sneak some time on the RH system tonight.
Rgds,
Posted: Thu May 24, 2007 5:16 pm
by chuckl
Edited the @stat in Sendmail.php to @lstat, and ran a send. Result:
Uncaught Error of type [Swift_Connection_Exception] with message [Sendmail cannot be seen with stat(). The command given [/usr/sbin/sendmail -bs] does not appear to be valid.]
Tried with a defined path and with AUTO_DETECT, same results.
Posted: Fri May 25, 2007 1:32 am
by chuckl
I'm beginning to suspect that they have PHP safe mode on on the server?
Posted: Fri May 25, 2007 2:29 am
by Chris Corbyn
chuckl wrote:I'm beginning to suspect that they have PHP safe mode on on the server?
What does phpinfo() show? SMTP would work with safe mode on, but processes cannot be created in safe mode.
Posted: Fri May 25, 2007 2:56 am
by chuckl
I'll check the phpinfo(), and yes, SMTP would work, but the stat() for the sendmail path won't. It's outside the web root. Crash burn etc.
Posted: Fri May 25, 2007 10:04 am
by chuckl
Nope, no Safe mode implemented. They must be using a chroot for each website or something similar. No access whatsoever outside the web root and the defined /usr/sbin/sendmail -t -i
Posted: Fri May 25, 2007 11:56 am
by Chris Corbyn
chuckl wrote:Nope, no Safe mode implemented. They must be using a chroot for each website or something similar. No access whatsoever outside the web root and the defined /usr/sbin/sendmail -t -i
You're chrooted? That explains it. I think apache/SuExec can be used to prevent access outside of the webroot too.
Thanks for pinning this down. I have considered writing a direct MTA/spooler connection for Swift in PHP alone (i.e. Swift writes messages to disk, and a PHP process is launched which runs all those messages off the spool... it's just a lot of work and will probably not meet all requirements of people).
Perhaps your host will be able to offer some advice on what to do next? You may find you can SMTP to localhost which will be pretty fast.
Posted: Fri May 25, 2007 12:04 pm
by chuckl
Running hosted sites chrooted is a growing trend. Could well be suExec or SuPHP as well, it's not my host, so my interest in the thing only extends as far as testing with Swift.
It just so happened that I was helping someone with another problem, so I had access to the RH machine. Needless to say they also have mail problems, so it is a good test case. Anything they send comes out vanilla text with variations.
Fortunately, I run my own servers, so I don't have those problems, but I'll post when I find either a solution or at least an explanation.
Thanks for your help Chris,
Rgds