Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

sent mail by perl

by Anonymous Monk
on Jul 27, 2001 at 14:46 UTC ( [id://100268]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

open (RMAIL, "|/usr/lib/sendmail -t"); select (RMAIL); $~ = "RESPONSE"; write; close (RMAIL);
The above script just sent the mail to the receiver if the email is valid, but it will not bounce back to the sender if the email is invalid. Any idea how to do the bounce back function?

Replies are listed 'Best First'.
Re: sent mail by perl
by Caillte (Friar) on Jul 27, 2001 at 15:00 UTC
    Different versions of sendmail differ in their switches but open((RMAIL, "|/usr/lib/sendmil -f me@my.host.com -t"); should work on most. Bounced email reports will then be sent to me@my.host.com

    Refer to man sendmail for details.

    $japh->{'Caillte'} = $me;

Re: sent mail by perl
by jepri (Parson) on Jul 27, 2001 at 14:54 UTC
    Bounce back can only be done by a mail server. It reads the return path in the envelope and send a bounce message back along the return path, to the user who sent it.

    The initial mail server (the one you are connecting to) is responsible for parsing the mail that you are sending, and building the envelope correctly. If it doesn't like what it's seeing, it will throw an error and your routine will fail, and then it's up to you to notify the user of the problem. Unless you are writing your own mail server you don't have to worry about bounces. If you are writing a mail server then you shouldn't be sending mail like that.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: sent mail by perl
by synapse0 (Pilgrim) on Jul 27, 2001 at 15:42 UTC
    Also, to talk directly with the sendmail server, check out Net::SMTP (which links to another node talking about returns from smtp), as it may be a little cleaner than calling sendmail through open().
    -Syn0
Re: sent mail by perl
by MZSanford (Curate) on Jul 27, 2001 at 14:53 UTC
    I would need to see the RESPONSE format to say for sure, but are you specifying a from and/or reply-to in the header ? If both are provided, i would suggest checking out some of the Mail::* modules for a better interface.
    Thus spake the Master Programmer:
    "When you have learned to snatch the error code from the trap frame, it will be time for you to leave."
    -- The Tao of Programming
Re: sent mail by perl
by Nitsuj (Hermit) on Jul 27, 2001 at 17:29 UTC
    First, the SMTP RFC is 821. You can view that here.

    Next, if you look on page 20 of that specification, it gives you the information on the RCPT command. There are 2 possible responses for an unknown user.
    1) Relay: Essentially, to do what you want would require you to put yourself into the "FROM" header of the e-mail. You will get the corresponding e-mail back.
    2) Error Code 550: The mail server could reply with an error code 550, "user unknown". In this case, you could write a program to recieve the error code and abort/notify/bounceback/whatever. Sendmail will give this error as "550: negative permanent filesystem." So, you could use sendmail's output to trigger this error.

    Of course, your program should do both so as to account for both.

    Just a bit of trivia here: Some sysadmins track this error as a means of detecting potential spammers... Also, some spammers/blackhats track this error as a means of finding valid users to spam/exploit.

    Just Another Perl Backpacker
Re: sent mail by perl
by Stegalex (Chaplain) on Jul 28, 2001 at 06:31 UTC
    Try MIME::Lite. Use its interface to stitch your mail piece together and to send it. As for bouncebacks, I have noticed that the big mail hosters (aol, hotmail, yahoo) and others have all abrubtly stopped sending failurenotices to my mail server. Sucks for those of us running OPT-IN mail lists. But hey, if you don't get failure notices, nobody's going to die are they?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://100268]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-25 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found