Bummer...

By "inactive" I mean if it never gets to an inbox because that email account no longer exists at that organization.

Sadly (I guess), it doesn't sound like this is something that's possible. However, when I was tinkering (which is about all I can really do with Perl) I came up with a script that checks for invalid / valid email accounts by trying to send a dummy email. Although I'm not sure if it's doing what I hope it's doing.

In the code below I have three email addresses from our organization domain name. The first in the array is a valid email (mine). The second and third are invalid. Seems to pull out the invalid ones like it should, and no actual email gets sent *shrugs*. Can anyone tell me what this is really doing?

#!/usr/local/bin/perl use CGI qw(:all); use Net::SMTP; # Checks email to see if it's active print header; gatheremails(); results(); ## GATHERS EMAILS sub gatheremails { # The first element of the array is my valid email, the others are dum +mies. @emails = ('jhess@wilcoxassoc.com','jhess1@wilcoxassoc.com','jhess +2@wilcoxassoc.com'); foreach $email(@emails){ checkit(); } } ## CHECK THE EMAIL BY DOING A MAILSEND ## WITHOUT REALLY SENDING ANYTHING sub checkit{ ## SMTP BEGIN $smtp = Net::SMTP->new('mail.wilcoxassoc.com'); # connect to an SM +TP server $smtp->mail('webmaster@wilcoxassoc.com'); # use the sender's a +ddress here $smtp->to($email) || addinvalid($email); # recipient's addre +ss # $smtp->data(); # Start the mail $smtp->quit; # Close the SMTP connection # If the flag shows it's not a bad email # then put in $email into the @valid array. if ($emailisbad ne "1"){ # GROWS AN ARRAY OF VALID EMAILS push(@valid,$email); } # Reset the flag to 0 for next email $emailisbad = "0"; } # PRINTS THE RESULTS TO THE BROWSER sub results{ print "<center><h2>Check for Active Emails</h2></center>"; print "<p>Active Email Addresses:"; print "<br>----------------------<br>"; if (@valid){ foreach $valid(@valid){ print "<li>$valid</li>"; } } print "<p>Inactive Email Addresses:"; print "<br>----------------------<br>"; if (@invalid){ foreach $invalid(@invalid){ print "<li>$invalid</li>"; } } } # GROWS AN ARRAY OF EMAILS THAT ARE INVALID sub addinvalid{ my ($errmsg) = @_; push(@invalid,$email); $emailisbad = "1"; }

In reply to Re^2: Finding out if an email is inactive by JaredHess
in thread Finding out if an email is inactive by JaredHess

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.