Mail function (Mailer Deamon)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Lancelot
Forum Newbie
Posts: 1
Joined: Wed Aug 07, 2002 11:46 am
Contact:

Mail function (Mailer Deamon)

Post by Lancelot »

I use a form on my site, the user can enter a mail-adress and then a mail is being send to that adress. I just use the function:
mail($to,$subject,$mail,$headers);
Now my problem is that when someone enters an invalid adress (like: qsdqsd@qsdqsd.com) a mailer deamon is being send to the host. My server admin has been complaining that he gets to many mailer deamons :) How can I prevent this, how can I let the mailer deamons being send to me and not to the server.
Putting "From: $from", "Return-To: $from", "Errors-To: $from" in the headers doesn't help. ($from is my email adress).

Does anyone knows a solution for this?

thx,
Lancelot
http://www.multiccianforce.tk
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

Hi there.

It's important that you have ONE newline after each headerelement.

Another way to do this is to use sendmail directly, invoke it with the "-f emailadress" then the bounced mail will got to that email.
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

you could also check to make sure that your user has an mx record with the getmxrr() function before you send them an email. If you don't want to write your own script for this, check evilwalrus.com or hotscripts.com - there are plenty already out there.
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

When you use mail() function on Unix server your outgoing e-mail ALWAYS have a header
'From: nobody@yourhost.com' (if httpd is run by nobody )

If you set 'From' header with mail() your recepient will see this header, but mailer deamon will use nobody@yourhost.com !!!


You can solve this with Mail class writen by
Chuck Hagenbuch <chuck@horde.org> . This PHP Class comes with PHP source code. iI have tested with sendmail and all is O.K. (but your admin myst add 'nobody' in sendmail trusted users list)
Post Reply