469,288 Members | 2,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

Dealing with Bounced Email

I've written a simple e-newsletter app using the PHP mail() command.

I want to be able to deal with bounce-backs if a member's email is no
longer working or is using an old account. I'm using a Red Hat Linux
server with Sendmail and Apache. I've seen mention of using Procmail or
filtering mail to a certain account through a PHP script, but, can't
find detailed instructions on how this is done.

Can anyone let me know or point me toward a site that explains how to
handle bounced-back email using Sendmail and a PHP script?

Thanks!

Jul 21 '05 #1
7 12189
Monty wrote:
I've written a simple e-newsletter app using the PHP mail() command. Can anyone let me know or point me toward a site that explains how to
handle bounced-back email using Sendmail and a PHP script?


Try this:

mail($To,$Subject,$Msg,$headers, '-f'.$returnaddress);
where $returnaddress = your email.

HTH

- Nicolaas
Jul 21 '05 #2
>"mail($To,$Subject,$Msg,$header*s, '-f'.$returnaddress);

where $returnaddress = your email. "


this would not help as the action is not automated... try setting up
an account that will be monitored by a script:
On receving mail, remove sender's adress from database, also search
body for e-mail adresses and remove them.

Jul 21 '05 #3
Ye*********@gmail.com wrote:
"mail($To,$Subject,$Msg,$header*s, '-f'.$returnaddress);

where $returnaddress = your email. "


this would not help as the action is not automated... try setting up
an account that will be monitored by a script:
On receving mail, remove sender's adress from database, also search
body for e-mail adresses and remove them.

It sounds like you have a mailing list and you are trying to automate the
remove response.

It is easier to let people go to a specific page to remove.

e.g.
click on the link to remove
http://www.yoururl.org/remove.php?client=1231232

then remove.php:

<?

if ( client_id_exists($client) ) {
if ( remove_client_from_database($client) ) {;
echo "thank you for taking the time. your address has been removed";
}
}

function remove_client_from_database {
runsql
}

etc....
?>
Jul 21 '05 #4
Ye*********@gmail.com wrote:
"mail($To,$Subject,$Msg,$header*s, '-f'.$returnaddress);

where $returnaddress = your email. "


this would not help as the action is not automated... try setting up
an account that will be monitored by a script:
On receving mail, remove sender's adress from database, also search
body for e-mail adresses and remove them.


Okay, but, how does one set up a PHP script to monitor bounced email
coming back to the account I've already set up? That's the part I have
no idea how to do.

Jul 22 '05 #5
windandwaves wrote:

It sounds like you have a mailing list and you are trying to automate the
remove response.


No, what I want to do is deal with the bounce-backs after sending a
broadcast email -- email that is returned because the email address is
no longer active or valid. I want to set up a PHP script to
automatically detect the returned email message, grab the email address
from the bounced back email, then remove that email from the database.

Specifically, I'm not sure how to go about using a PHP script with
Sendmail to lift the TO: email address from a bounced back email when
it is returned to the email account i have set up as the Return Path.

Jul 22 '05 #6
>> >"mail($To,$Subject,$Msg,$header*s, '-f'.$returnaddress);
>
>where $returnaddress = your email. "


this would not help as the action is not automated... try setting up
an account that will be monitored by a script:
On receving mail, remove sender's adress from database, also search
body for e-mail adresses and remove them.


Okay, but, how does one set up a PHP script to monitor bounced email
coming back to the account I've already set up? That's the part I have
no idea how to do.


There are several approaches:

(1) If you have a system which supports it (e.g. Linux or UNIX using
sendmail, smail, Exim, etc.), you can forward mail received by a
user into a pipe by specifying this in a .forward file in the user's
home directory. The program (which could be written in just about
anything: standalone PHP, Perl, sh, C, or whatever) will be invoked
with the email text (including the headers) on stdin. Details of
what user the program will run as or what the current working
directory will be may vary. Whether or not the admin has turned
this off or not may vary also. It is up to the program to go
through the headers and body to figure out what to do with it.

(2) You could set up a cron job which periodically invokes a program
which polls a mailbox using POP3, IMAP, or just opens the mailbox
file directly. For example, fetchmail can be used to transfer the
mailbox contents to a local file. Then a program could look at
what came in. The host with the program doesn't have to be the same
host as the one with the mailbox, in the case of POP3 or IMAP polling.

Gordon L. Burditt
Jul 22 '05 #7
On 2005-07-22, Monty <mo****@hotmail.com> wrote:
Specifically, I'm not sure how to go about using a PHP script with
Sendmail to lift the TO: email address from a bounced back email when
it is returned to the email account i have set up as the Return Path.


man procmail
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rob Imbeault | last post: by
3 posts views Thread by Jishnu | last post: by
2 posts views Thread by DaveF | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.