Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Re: Resending a complete e-mail

by fsn (Friar)
on Nov 05, 2002 at 09:48 UTC ( #210416=note: print w/replies, xml ) Need Help??

in reply to Re: Resending a complete e-mail
in thread Resending a complete e-mail

Ok, this is my standard rant about sending email from scripts, being a former system administrator of a mail system for 40.000+ users. If you are using this in anything else than a very trivial testing-only environment, 'mailhost' in Jenda's example above should be set to 'localhost' and you should run an SMTP daemon on your localhost. This is for reasons of error handling and redundancy. This is also true if you are running this in a cgi script on a webserver. You want to send the email as quickly as possible to be able continue with the cgi script, and sending the mail to localhost is a lot quicker than over the network.

If you are not able to run an SMTP daemon on localhost, you can use it the way Jenda describes above, if mailhost is close to you, and under your control. This is a riskier solution, and will not take advantage of MX records (think sendmail 'smarterhost' set to an MX record of mailhost1, mailhost2 & mailhost3 (or, as in my case, virusscanner1, virusscanner2, virusscanner3...)).

Anyway, always check that new creates a valid $smtp object. If you get undefined or something, the connection with mailhost could not be established, and you will have to deal with that.

Don't even think about sending the mail directly to the recipient's mailhost. You won't be able to deal with spooling, error handling, DNS resolving and cacheing, MX records etc. as efficiently as sendmail (or other MTA's).

Replies are listed 'Best First'.
Re: Re: Re: Resending a complete e-mail
by Jenda (Abbot) on Nov 05, 2002 at 13:45 UTC

    Agreed. Thanks for writing this.

    I took the code directly from Net::SMTP's docs and only deleted a few lines and changed it a little.

    I think it's all too common that even the most well known modules miss any error checking in the examples included in the docs. :-(
    Sorry I did not add it ;-)


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://210416]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-12-09 02:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found