Email::Valid does not actually attempt delivery. From its documentation:
This module determines whether an email address is well-formed, and optionally, whether a mail host exists for the domain.Please note that there is no way to determine whether an address is deliverable without attempting delivery (for details, see perlfaq 9).
So, let's start today's SMTP lesson:
Depending if the address is valid, you may get a response back from the mail server immediately (or you may not find a host, or be able to connect to port 25, letting you know something's wrong). It's also possible that the server you connected to has no idea about the final mail delivery, and is just there for load balancing, virus scanning, spam filtering, or something else where it doesn't know at this point that the recipient is over quota.
(of course, you wouldn't actually do all that by hand, I just needed to explain the steps... you should use Net::SMTP or one of the other mail sending modules in CPAN ... see How do I send e-mail from my Perl Program?)
If the email is found to be undeliverable, it will send a message to the envelope-from. (that's the email address in the 'MAIL FROM' line, which doesn't necessarily need to be the same as the 'From' header.) So, you have to send out the messages with a valid e-mail address as the recipient from, and then have some sort of process to connect to that account (see Net::POP3 or Net::IMAP::Simple) and check for errors. (or spam collecting up). You could also use something to process the mail on the mail server, potentially (see What're some good ways of notifying a perl script of an incoming email?)
So um...you'd probably do better just reading perlfaq9
Update: I should probably mention -- most e-mail servers will attempt to deliver messages to servers that are down. (ie, you can't connect on port 25). You might get a message that it's having problems after a few hours, but you can't depend on it. Sendmail (which is so widespread we'll use as our standard) sends its final 'I've given up' message after 5 days. You also run the risk of the e-mail being dropped by any server, thinking that your message is spam, or a virus, or just because of problems. So remember -- it can take almost a week to go through, and you can't be sure that you'll get an error message if it doesn't go through.
In reply to Re^2: Yet Another E-mail Validation Question
by jhourcle
in thread Yet Another E-mail Validation Question
by tanger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |