I'm trying to send some emails with Net::SMTP, and all goes well except that I can't figure out how to tell if the mail was sent successfully. I have to record which emails are real and which receive a "User Unknown" response.

I saw this post Net:SMTP Printing to STDOUT, and according to that, and the Net::SMTP manual and Net::Cmd manual, I should do this:

$smtp = Net::SMTP->new('smtp.host.com'); $smtp->mail('someone@example.com'); $smtp->to('someone@example.com'); my $ret = $smtp->data($maildata);

If my $ret value is true, it was a sucess. If false, the mail was not sent.

That works fine when the recipient's domain is handled by the same host as I am using as my SMTP relay (smtp.host.com) but if I am sending to a non-existing recipient on another host, I want to receive false, or a "User Unknown" message. Instead, it returns true.

Any ideas how I can figure out if the mail made it without parsing the maillog, and without doing a lookup on each mailaddress, and using their MX record instead of smtp.host.com ?


In reply to Net::SMTP success / failure response by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.