[Catalyst] SMTP vs sendmail

Jason Kohles email at jasonkohles.com
Fri Aug 31 13:39:31 GMT 2007


On Aug 31, 2007, at 7:23 AM, Carl Johnstone wrote:

>> SMTPing to localhost usually doesn't make much sence - it is slow  
>> and as
>> you mentioned already it causes trouble when the daemon is down or  
>> slow.
>>
>> So either you want to do queueing overhead, dns resolving and  
>> SMTPing to
>> the *remote* host yourself or you simply open(MAILER,"|sendmail  
>> @args").
>
> Using |sendmail means you've got the overhead of forking a separate  
> process, SMTP to localhost the overhead is making the socket  
> connection. Once it gets to your MTA it'll pretty much do the same  
> in either case.
>
Except by piping to sendmail, you can also specify -odq, which says  
to sendmail 'dump this into the mail queue and return immediately, I  
don't want to wait for delivery to work' which can make the  
application much faster and leave the mail delivering to sendmail.

> Piping to sendmail also has the disadvantage that in many cases  
> it'll leave www-user at hostname.example.com in the headers, using  
> SMTP means your message doesn't get mangled.
>
Not necessarily, if you don't manage the mail server you are  
connecting to, then your headers might get mangled anyway, if you do  
manage the mail server, then you can easily correct the configuration  
to not leave www-user at hostname.example.com in the headers.

> To be honest the best solution to to make use of your ISPs outgoing  
> mail gateway/smarthost. It'll be the most reliable mail server on  
> their network, and you've only got the overhead of an outgoing  
> socket connect.
>
The best solution would be to do both, use sendmail on the web server  
to deliver into a local mail queue which is forwarded to the  
smarthost for delivery.  That way you get the advantage of having the  
mail server handle the mail, while freeing you from having to write  
your own version of sendmail to deal with these situations:

* What does your application do if the smarthost is getting pounded  
by spammers and that outgoing socket connect fails?
* What does your applicaiton do if the smarthost is down for  
maintenance or hardware failure?

In both of these cases, if you were piping to sendmail and letting  
the local MTA handle the relay to the smarthost, then the mail would  
simply be queued until the mail server was available again.

-- 
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the Catalyst mailing list