Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set up bounced message to specified email

Status
Not open for further replies.

aas1611

Programmer
Dec 14, 2001
184
DE
Hi,

I've tested my mail function, see if it bounced back to me if the email I sent to is unknown. But I haven't received anything yet.

Here is part of my header, using reply-to and return-path:

Code:
...
header .= "Reply-To: andre@andre.de <andre> \n";
header .= "Return-Path: andre@andre.de <andre> \n";
...

No bounced message came to my email above.

Where did it go wrong?

Thanks!

Andre
 
I already switched it but still didn't work.

Here is my real code:
Code:
$header  = "From:Andre Sasongko<a.sasongko@mediass.de> \n";
$header .= "Reply-To:Andre Sasongko<a.sasongko@mediass.de> \n";
$header .= "Return-Path:Andre Sasongko<a.sasongko@mediass.de> \n"; 
$header .= "Return-Receipt-To: Andre Sasongko<a.sasongko@mediass.de> \n";
$header .= "Content-type: text/plain; charset=iso-8859-1 \n";

Do the header commands have to be in certain orders?
Is the problem all about this script or I have to somehow configure my mail server?
 
does email get through to known addresses?
what is the code you are using to send the emails?
what operating system are you using?
what MTA are you using?
 
1. Yes, the email gets through to known addresses.

2. The code to send emails: mail($e_mail,$betreff,$mailtext,$header)

which,
$e_mail is the target address
$betreff is subject
$mailtext is the text

3. I'm using windows 2000, and my users use XP.

4. I'm not sure what MTA is...
 
MTA is the mail transfer agent.

in the php.ini file you are pointing to an outgoing smtp mail server. it is important to know what this is as it may well override settings for failed emails.

you should also check you php.ini file for the sendmail_from directive.

change your code to
Code:
mail($e_mail,$betreff,$mailtext,$header) or (echo "problem sending mail");
this will give you feedback if the mail call itself fails. note that this is not the same as a delivery or non-delivery report.

ensure in your email headers you are NOT using the <> syntax for mail addresses. JUST include the email address.
 
I will try your suggestion.

About <> syntax, I've read that this is used to avoid our emails end up in junk mails or are considered as spam. So, is it true?
 
About <> syntax, I've read that this is used to avoid our emails end up in junk mails or are considered as spam. So, is it true?

i don't know about that. i suspect that matching contents of the angle braces with email addresses is just one of the heuristics that anti-spam software uses. i have no evidence of it though.

my concern is that php reports that use of the angle-braces in email addresses sent through the mail command to an smtp server causes problems in the parsing of the mail command. this is because php parses them itself rather than sending them to the mailserver for processing.
 
Here is the thing, I forgot to mention it before:

I'm afraid I can't access php.ini as we use an outside vendor for our web server. I already sent them email regarding this topic. I don't know if they can or want to change the setup accordingly. I really doubt it.

If this is the case, do you have any other suggestions?

Andre
 
upload a script to your server that consists of
Code:
<? phpinfo(); ?>

that should give all the information that is in the php.ini file. let us know about the mail bits.
 
Here are the informations in php.ini regarding mail:

sendmail_from: root@localhost.com
sendmail_path: /usr/sbin/sendmail -t -i
SMTP: localhost
smtp_port: 25

They are the value of both local and master value.

are they any help?
 
another question i'm afraid: is your host running linux or windows.
 
It is running linux (with Apache 1.3,if it helps...)
 
ok

im far from an expert on sendmail. i believe that the issue is one of configuration of the sendmail package rather than of php.

however one thing to try first: try keeping the headers really simple and include the Errors-To header:

Code:
$validemail = "validemail@email.com";

$headers = 'From: $validemail' . "\r\n" .
   'Reply-To: $validemail' . "\r\n" .
   'Errors-To: $validemail' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();


 
Have tried that. Unfortunately still didn't work. At least, an hour after I sent to an unknown email, I stil haven't received the bounce error yet.

kind of frustrated...
 
i believe that the issue is one of configuration of the sendmail package rather than of php.

talk to your server host. i get the same behaviour from my linux servers.

alternatively - have a look at phpmail in the pear repository (pear.php.net). i *believe* that this does not use sendmail but rather sends the mail out itself (i.e. finds the mx record for the recipient, opens a socket and sends the mail). if phpmail does not then for sure there are others that do.

installing pear on a remote server that you have no control over is a challenge but possible. upload go-pear.php first. (find it at go-pear.org.
 
Thank you for your effort. I will talk to them.

Supposed I was able to modify the php.ini, would that help, and which directives should I change?

Thanks!

Andre
 
i dont think that php.ini will make a difference for you on this one. but you will probably find that you can upload your own php.ini file to the directory that you are running the scripts from and that the settings in that file will override the master settings.
 
The technical support from my host told me that I should use -f parameter in my script. But he didn't specify how. Do you know how to use -f parameter in the header?

Have been looking around about this -f parameter but nothing suits my problem.
 
i suspect that he means in the php.ini file.

however all this does is set the from address, which the header should do in any event.

but it's worth a try. insert this at the top of the code that sends an email and see what happens. It also forces the error mode:

Code:
ini_set ("sendmail.path", ini_get("sendmail_path") . "-fYOURADDRESS@YOURDOMAIN.COM  -OErrorMode=m ");

provided your provider has not closed off this route to modify the ini file it should work. you can test it by adding the line
Code:
phpinfo();
after the ini_set. it will then tell you whether the sendmail path has been successfully modified.

please note that you should not leave a space between the f and YOURADDRESS (it doesn't matter too much if you do but better practice not to). and note of course that you must replace the YOURADDRESS@YOURDOMAIN.COM with a valid email address.

good luck
Justin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top