Swiftmailer Operation
Moderators: Chris Corbyn, General Moderators
Swiftmailer Operation
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,
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,
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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.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.
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.
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,
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,
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Sussed it. Symbolic links are not followed with stat(). They'll be a simple fix for thischuckl 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,
EDIT | Indeed, changing stat() to lstat() is the fix.
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.
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.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You're chrooted? That explains it. I think apache/SuExec can be used to prevent access outside of the webroot too.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
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.
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
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