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).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.