Using Perl to send emails directly to recipients mail servers
I need to write a small Perl application to send email directly to the recipients' mail servers. I can't use a local mail server because I need 开发者_如何学编程to know about email errors immediately when they happen.
I know about Email::Sender and Net::SMTP, but are there any Perl modules that will handle the MX lookups, and possibly even the retries?
Very few SMTP servers, today, would accept mail from stand alone machines not configured as Relays - especially if they do not reverse resolve to the sending domains MX record. However if you are willing to wait for a (configurable) short time to know what happened to your email, here are a few options that you could consider on a properly configured SMTP Relay:
- Use a Daemon that scans the mail log (for example if you are using Postfix look at: Mail::Log::Parse::Postfix and logs each entry some place that your program can access
- Again using Postfix as an example, keep the deferred deadline very short so that deferred mail is bounced
- Add a Custom Header to your mails so that a POP daemon can track bounces possibly using Mail::DeliveryStatus::BounceParser
I know thats a lot of work for something seemingly simple as checking what happens to your email, but this is the best you can do if you insist on not using Net::SMTP :) while also avoiding the risk of SMTP servers refusing your mail
精彩评论