bounced emails going to nobody

ramorse

Well-Known Member
Sep 6, 2003
254
5
168
cPanel Access Level
Root Administrator
I have several accounts that we developed php scripts for that send out emails to people such as postcard scripts, or scripts that send out to a list of selected people. If the script sends out to a bad email address the bounce messages get sent to nobody which then get forwarded to me as server admin even though there is a specific user's email address in the from field in each message that goes out.

I am assuming then, that the server is inserting the nobody address somewhere in the header of each email. Is there a configuration on the server that inserts the senders email in the right place in the header?
 

dezignguy

Well-Known Member
Sep 26, 2004
533
0
166
It's the Return-path: in the header...
Exim seems to have been changed by cpanel to no longer automatically figure out where these emails should really go.

There are a number of other threads here discussing this... search for them for more info.
 
Oct 8, 2003
21
2
153
I've been following this one up to.

It appears you have to enable phpsuexec and rebuild apache, so the php scripts
will run under the ID of the user and not nobody.
Then you have to ensure the scripts are chmod'd like perl scripts to get them to
work correctly.

Did that, it caused a configuartion error apache page to appear, i think something
needed updating in the httpd.conf file.

So i recompiled without it.
I thought, why go to all this trouble when it wasn't using phpsuexec in the first place
and the return to path used to work.

The odd thing is, if the mail address is correct, then the reply-to is the sender address
of the mail and not [email protected]
It appears EXIM is adding the return-path [email protected]
so bounded e-mails from all the hosting accounts come bouncing back to the
server admin acccount for php based apps, since they run as nobody.

That was my question, without using phpsuexec, how can EXIM be changed to
figure things out like it used to.

On i plod!!!

If you get an answer before i do, please update this thread.
 
Oct 8, 2003
21
2
153
return-path nobody bounced mail in PHP - Solution

Thanks to those members who have posted the solution,
here is the implementation notes for those a little more challenged:

Open "WHM"
Under "Service Configuration" , click "Exim Configuration Editor"
Click "Switch to advanced mode"

In the first editable text box below
#!!# cPanel Exim 4 Config:

ADD:

local_from_check = false
untrusted_set_sender = root


In the textbox that follows (REWRITE CONFIGURATION)
begin rewrite:

ADD:

[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs

NOTE: there is no space between fai and l in the word fail above.
There appears to be a text translation problem in the forum.


Now Click Save, Exim will restart with the updated config.
It now works ( it does for me ).
One note worth mentioning, the TextBoxes were empty prior to
me populating them.
 
Last edited:
Oct 16, 2004
11
0
151
neil_rutherford said:
Thanks to those members who have posted the solution,
here is the implementation notes for those a little more challanged:

Open "WHM"
Under "Service Configuration" , click "Exim Configuration Editor"
Click "Switch to advanced mode"

In the first editable text box below
#!!# cPanel Exim 4 Config:

ADD:

local_from_check = false
untrusted_set_sender = root


In the textbox that follows (REWRITE CONFIGURATION)
begin rewrite:

ADD:

[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs



Now Click Save, Exim will restart with the updated config.
It now works ( it does for me ).
One note worth mentioning, the TextBoxes were empty prior to
me populating them.
This method did not work for me. if someone has the solution please let me know. Thanks. :) I'm actually looking through this thread too. Not sure if it is the same problem.
 
Last edited:

FWC

Well-Known Member
May 13, 2002
354
0
316
Ontario, Canada
lemonsensation said:
This method did not work for me. if someone has the solution please let me know. Thanks. :) I'm actually looking through this thread too. Not sure if it is the same problem.
Remove the spaces between the i and l in the word fail in each line. That will break the rewrite and prevent it from doing it's job. It worked for me after I fixed them.
 
Oct 8, 2003
21
2
153
It must be a forum problem.

I copied the rewrite rule and it appears ok without the space between fai and l
You view it and it appears with a space.
You edit it the text to update it and no space.... must be text translation in the forum
that is doing this.
 
Oct 16, 2004
11
0
151
crap, actually my problem with PHP scripts is a little bit different than yours. My problem with PHP scripts is that when the php script tries to send out an email, it sends the email as "[email protected]" when the web address and MYHOSTNAME are totally different. So to solve this problem, I turn on "Prevent the user 'nobody' from sending out mail to remote addresses (php and cgi scripts generally run as nobody if you are not using phpsuexec and suexec respectively.)"

After doing that, emails get stuck in the Mail Queue. It says the email it was trying to send to has an "unrouteable mail domain".

I tried the PHPsuexec and it fixed the problem. However, I would like to keep phpsuexec off, if possible. So I try out this solution by modifying Exim. At first it didn't work at all because of the "fai l" problem. After fixing it, the email instead of going to the mail queue, it gets sent to :blackhole: with the same error saying "unrouteable mail domain".

The php script I am using is Drupal. I'm using WHM 9.9.7 cPanel 9.9.8-S6. Basically, emails are being sent out as nobody even though I have configured Drupal. Works fine with phpsuexec but I would like to keep phpsuexec off.

UPDATE: I made my own thread since my problem is different than yours. It is here: http://forums.cpanel.net/showthread.php?p=151092#post151092
 
Last edited:
Oct 8, 2003
21
2
153
PHP:
actually my problem with PHP scripts is a little bit different than yours. My problem with PHP scripts is that when the php script tries to send out an email, it sends the email as "[email protected]" when the web address and MYHOSTNAME are totally different.
From what you are saying above, it's symptomatic of what i had.
PHP was sending mail as [email protected] because phpsuexec was off and apache uses nobody
account.
phpsuexec is still off, i applied what was written above and now all PHP mail
sent via the PHP scripts i have written go via their account and host name and any
are returned mails are returned to the account that sent them, not nobody.

You might have other config parameters configured differently which is stopping you achieving your goal.
 

ccccanada

Well-Known Member
Jan 17, 2003
279
0
166
Hello Neil!

The fix that you have posted in this thread worked great on all my servers.

Mail is still being send by [email protected] but when there are any bouces it gets returned to the sender address.

Thank you for posting it here I did a search for this a few times now but never found the fix anywhere else.
 
Oct 16, 2004
11
0
151
neil_rutherford said:
PHP:
actually my problem with PHP scripts is a little bit different than yours. My problem with PHP scripts is that when the php script tries to send out an email, it sends the email as "[email protected]" when the web address and MYHOSTNAME are totally different.
From what you are saying above, it's symptomatic of what i had.
PHP was sending mail as [email protected] because phpsuexec was off and apache uses nobody
account.
phpsuexec is still off, i applied what was written above and now all PHP mail
sent via the PHP scripts i have written go via their account and host name and any
are returned mails are returned to the account that sent them, not nobody.

You might have other config parameters configured differently which is stopping you achieving your goal.
Hi, Yah you are right neil_rutherford. ccccanada pointed it out in my other thread. I had
Prevent the user 'nobody' from sending out mail to remote addresses (php and cgi scripts generally run as nobody if you are not using phpsuexec and suexec respectively.)
enabled and phpsuexec disabled so it just wouldn't allow PHP to send emails at all even though I added your code. In order for you code to work, I need to keep "Prevent the user 'nobody' from sending out mail" OFF and phpsuexec OFF. Thanks. :)
 
Oct 8, 2003
21
2
153
I'm using the following stable version:

WHM 9.9.7 cPanel 9.9.8-R5
RedHat Enterprise 3 i686 - WHM X v3.1.0

Attached is a copy of the servers exim.conf that cpanel merges with the changes
i've added via the cpanel admin tool.
Compare it to see what is different with your settings.

Or, upload it to your server, and copy it to
/etc/exim.conf
and restart exim.

It sends e-mail as [email protected] and return path is [email protected] (for example).

I've included a php test mailing script you can run.

Don't forget to rename both files attached to
exim.conf and email-test.php

Update the from and to address in the top of the email-test.php

Neil.
 

Attachments

netlook

Well-Known Member
Mar 25, 2004
335
0
166
neil_rutherford said:
[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs
It works great, but if there is no "From:" header, mails are bounced to root.
So how to modify those lines to make such thing:

bounced messages are delivered to sender (not nobody) and if there is no valid sender they are simply deleted and not send to root.

Hope you will help me :eek:
 

we_are_borg

Member
Mar 16, 2003
18
0
151
i'm gettin a error in the line below the other one is working as far as i can tell at the moment.

But when i did this earlyer it was working but now it doesn't. Can some one advice me.

Code:
error in ACL: unknown ACL verb in "[email protected];/etc/localdomains "${if !eq {$header_From:}{}{$header_sender:$header_From:}fail}" Fs"
The fail is not fai l but it reads fail
 

ttremain

Well-Known Member
Feb 16, 2003
237
1
168
cPanel Access Level
Root Administrator
Sounds like the scripts are using incomplete headers... Fix the scripts to append return headers in the mail() command.

Code:
//set the mail message up 
$mailheaders="From: [email protected]\r\n" .
     "Reply-To: [email protected]\r\n" .
     "X-Mailer: PHP/" . phpversion();
mail($to, $subject, $body, $mailheaders);
If the mail() command is formatted properly in PHP, the returns go to the right
place, and you don't have to have phpsuexec.

__________________
Thomas Tremain
LiveHost.net Web Hosting
GotoNames.com Domain Name Registration
TrafficExaminer.com web site stats for professionals
 

spaceman

Well-Known Member
Mar 25, 2002
509
5
318
Much to my surprise, this worked for me without editing exim.conf (note the -f option in the 5th parameter $more). I'm running exim-4.52-7.

PHP:
<?php
$to      = "[email protected]";
$from    = "[email protected]"; 	 
$subject = "the subject";
$message = "the message";
$headers = "From: $from";
$more    = "-f$from";

mail($to, $subject, $message, $headers, $more);

?>
 

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
Brisbane
cPanel Access Level
Root Administrator
Yes you can of course use the correct sendmail -f command at the fifth argument of the mail() function.

But try getting all your hosting clients to edit their scripts like osCommerce and all the others that don't use the fifth argument of sendmail. It just doesn't happen.

For hosting providers it must be tackled at the server end not the PHP files.

Just my 2 cents.

Thanks for the great thread.

Aaron
 

spaceman

Well-Known Member
Mar 25, 2002
509
5
318
aarondwyer said:
Yes you can of course use the correct sendmail -f command at the fifth argument of the mail() function.

But try getting all your hosting clients to edit their scripts like osCommerce and all the others that don't use the fifth argument of sendmail. It just doesn't happen.

For hosting providers it must be tackled at the server end not the PHP files.

Just my 2 cents.

Thanks for the great thread.

Aaron
Absolutely right. The -f php mail solution only applies where the code is your own and/or you're prepared to hack/mod 3rd party software.