Forum Moderators: mack
How can I prevent sendmail from reporting errors with an email address?
Help very much appreciated.
There are 2 things to consider:
(1) retracting the ability to send a confirmation mail to arbitrary mail addresses at all, because this may perhaps be misused for spamming, depending on your form of course.
(2) check the mail-address string for a valid syntax before passing it to sendmail.
You may look into this thread for further hints
[webmasterworld.com...]
or browse thru the other results you get when asking Google for
perl validate mail address
HTH and regards,
R.
# send mail to $recipient
$mailprog = '/usr/lib/sendmail';
open (MAIL, "?$mailprog $recipient")? die "Can't open $mailprog! $!\n";
print MAIL "From: me\@example.com\n";
print MAIL "To: $recipient\n";
print MAIL ...other stuff ...;
...
You may look at the sendmail's -O options "DeliveryMode" or "ErrorMode" and probably look thru your sendmail.cf config file.
Otherwise, you could indeed try to verify the address the hard way by
-- looking up the MX record of the domain in the DNS
-- open a socket connection on port 25 (SMTP) to the mail server found in MX and
-- start a HELO/EHLO mail conversation
-- entering a RCPT TO: user@domain
and look for any 200 OK or 4xx/5xx reject messages from the target mail server. Depending on the server's spam policy, this may often work and sometimes not.
However, while being there, then you could also deliver the remaining mail body by hand and would not need a sendmail after all ... :-)
Regards,
R.