Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: SendMail works 99% of the time

by hagus (Monk)
on May 19, 2002 at 11:38 UTC ( [id://167639]=note: print w/replies, xml ) Need Help??


in reply to SendMail works 99% of the time

It is a little unclear what you are after here. Where are you calling sendmail from? I assume from a CGI program hosted somewhere. If so, it depends on the type of error you're getting. If delivery failed because sendmail returned an error code, you can obviously test for that.

If delivery is failing and being reported back with a bounce, that won't be recorded in the sendmail logs, AFAIK. What will happen is that a bounce will be generated and e-mailed to the originator of your message (using the reply-to address I guess).

So ... you could do something like have procmail running somewhere in some special user account, invoking a script that you've written which parses bounce e-mails. Make sure the user running procmail is set as the reply-to of outgoing e-mails. Attach an X-header so you can match up replies with transmission attempts. And Bob's your father's brother.

Seems like the best way to me - because if your hosting service's sendmail can't transmit the message, *it* will return a bounce. But what if the remote mailbox is full? Then the destination SMTP server will generate the bounce, and your hosting service's sendmail will calmly deliver that without a second glace. Sendmail doesn't parse incoming e-mails to determine whether they are bounces for something it has transmitted in the past. So your hosting providers logs of bounces (if they exist) won't contain the whole story.

Just thinking off the top of my skull, HTH - HAND.

--
Ash OS durbatulk, ash OS gimbatul,
Ash OS thrakatulk, agh burzum-ishi krimpatul!
Uzg-Microsoft-ishi amal fauthut burguuli.

Replies are listed 'Best First'.
Re: Re: SendMail works 99% of the time
by Elliott (Pilgrim) on May 19, 2002 at 19:37 UTC
    OK, let me try for a little more clarity...

    I am calling SendMail from a cgi script. Bounces, non-receipts etc are not the issue. The issue is that the emails are not being sent every time. I assume this either because of a SendMail error or because of a failure to launch it.

    Hagus says "If delivery failed because sendmail returned an error code, you can obviously test for that." which is exactly my problem! I don't know how to log the error.

      After you call the sendmail binary, you can interrogate the $? variable for the exit code of sendmail. I am guessing that '0' means success, although the sendmail man page does not seem to list exit codes.

      After your open using pipes or system call, or whatever you use to invoke sendmail:

      # -- insert sendmail invocation here. # eg. open(SENDMAIL, "|/usr/bin/sendmail -t") $exit_value = $? >> 8; $signal_num = $? & 127; $dumped_code = $? & 128;
      (from the Cookbook)

      Anyway, how do you know that bounces are not the issue? Is the user who is sending the messages getting none at all? Maybe start off by checking the return values as above, but if sendmail is being run successfully and you are missing out on mails, I would look for bounce messages.

      --
      Ash OS durbatulk, ash OS gimbatul,
      Ash OS thrakatulk, agh burzum-ishi krimpatul!
      Uzg-Microsoft-ishi amal fauthut burguuli.

        --how do you know that bounces are not the issue?-- Because I copy the emails to myself - and when the client doesn't receive them, netiher do I. Thank you for the exit codes. I'll do some experimenting with those.
Re: Re: SendMail works 99% of the time
by Juerd (Abbot) on May 19, 2002 at 19:03 UTC

    Ash OS durbatulk, ash OS gimbatul, Ash OS thrakatulk, agh burzum-ishi krimpatul! Uzg-Microsoft-ishi amal fauthut burguuli.

    What does that mean? In case you hadn't noticed, this site is in English :)
    Update: How could I have been so foolish...

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      It's the inscription on the Ring of Power, sought after by Bill Gates, to make his conquest of Middle Earth complete.

      In the Orcish tongue of Microsoft it reads: "One OS to rull them all, one OS to find them, one OS to bring them all and in the darkness bind them. In the land of Microsoft where shadows lie."

      Let us hope I never have to utter those words here again. This is supposed to be a holy place.

      --
      Ash OS durbatulk, ash OS gimbatul,
      Ash OS thrakatulk, agh burzum-ishi krimpatul!
      Uzg-Microsoft-ishi amal fauthut burguuli.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found