mod_ruid2 and sendmail return envelope path

LavantiS

Verified User
Joined
Apr 19, 2012
Messages
10
Hello everyone,

recently I installed on my CentOS box the ruid2 mod to apache in order to eliminate problems in file / directory permissions for CMS like joomla, etc..

Since that time, the

Code:
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f USERID@USER's DOMAIN'

directive in the httpd.conf for every domain was working great and each message had the correct Envelope-from header (the directadmin user @ user domain name email address).

After the mod_ruid2 installation the above directive stopped working.

So every email initiated by php's mail() is having as an envelope-from (and return path / bouncing) email address
USERID @ localhost.servername which ofcourse is invalid and stays in the queue..

Is there a way to re-estate the USERID@userdomainname header as it was, without loosing the ruid2 php running as user functionality?

Thank you in advance,

Minas
 
Is there any reason you can't use email injection on localhost instead of calling the sendmail interface?

Jeff
 
by email injection you mean using the 5th parameter in mail()? Constructing my own headers for envelope-from - Return-Path etc?

I tried that with a simple php mail script under a virtual site that runs with mod_ruid2 but with no luck.. In the details headers of the email you can still see the
unix user @ (local server name + domain) no matter what. And editing every script in all virtual sites / domains hosted on the server is out of the question..
 
In case this helps:

this is how it was the standard mail headers for a random website:


----------------------
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from host.servername.com (unknown [xxx.xxx.xxx.xxx]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by somedomain.com (Postfix) with ESMTPS id 70C66CF7D1 for <[email protected]>; Wed, 5 Jan 2011 10:08:39 -0800 (PST)
Received: from apache by host.servername.com with local (Exim 4.67) (envelope-from <[email protected]>) id 1PaXnZ-0007cq-GU for [email protected]; Wed, 05 Jan 2011 20:09:25 +0200
To: [email protected]
Subject: some subject
X-PHP-Script: www.userdomain.com/index.php for xxx.xx.xxx.xxx
Date: Wed, 5 Jan 2011 18:09:25 +0000
From: Sender Name <[email protected]>
Message-ID: <[email protected]>
X-Priority: 3
X-Mailer: PHPMailer (phpmailer.sourceforge.net) [version 2.0.4]
MIME-Version: 1.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"
Sender: <[email protected]>
--------------------

You can see above that the user apache was delivering the email to exim forsending but the return path & envelope-from are displaying the userdomain for the specific site..

After the mod_ruid2 installation for a similar email sent through the same site:

-------------
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from host.servername.com (unknown [xxx.xxx.xxx.xxx]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by somedomain.com (Postfix) with ESMTPS id ED5EA72C4B0 for <[email protected]>; Sat, 31 Mar 2012 02:04:10 -0700 (PDT)
Received: from user1 by host.servername.com with local (Exim 4.67) (envelope-from <[email protected]>) id 1SDuE9-0006gr-Ag for [email protected]; Sat, 31 Mar 2012 12:04:05 +0300
To: [email protected]
Subject: some subject
X-PHP-Script: www.userdomain.com/post.php for xxx.xxx.xxx.xxx
Date: Sat, 31 Mar 2012 09:04:05 +0000
From: Sender Name <[email protected]>
Message-ID: <[email protected]>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
Reply-To: [email protected]
X-Mailer: PHP/5.2.14
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"
Sender: <[email protected]>
--------------


So, now (since apache runs the php script with the user1 userid), now user1 is delivering the email to exim for further processing (instead of apache).
The Return Path, Envelope-From, Sender and similar data while are still getting the user1 as they should, they don't get the "@userdomain.com". (My opinion is that this was forced through the
Code:
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|'
directive on each virtual_host.conf (httpd.conf))

instead, the local host servername "@host.servername.com" appears in every email sent through php / httpd for all different users / virtual hosts / sites hosted on the same server.

I would like to have the email headers it as they were, without loosing the mod_ruid2 benefits..

Hope it's prety clear now!
 
Actually that should be the correct syntax on template (|USER|@|DOMAIN|).

If you open for example /usr/local/directadmin/data/users/admin/httpd.conf

You should have admin@domain, am i right?

Can you provide a simple mail script i should test (sorry im not a programmer).

Thanks

Regards
 
I know that this is correct and that's the way it should be .. But when you enable mod_ruid2 this parameter seems to make no difference at all..

Find below a small php script (save it as email.php and run it from a virtual host user account) and change from / to email addresses / names as you wish..


PHP:
<?php
$to = '[email protected]';
$from = '[email protected]';
$fromname = 'Minaras';
$subject = 'HTML Email';
$headers = "Date: ".date('r')."\n";
$headers .= "Return-Path: ".$from."\n";
$headers .= "From: ".$fromname."\n";
$headers .= "Message-ID: <".md5(uniqid(time()))."@anotherdomain.xxx>\n";
$headers .= "X-Priority: 3\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= 'Content-Type: text/html; charset="utf-8"'."\n";
$body ='
HTML Email Body
';
mail($to, $subject, $body, $headers);
?>
 
With this code email came from minaras@hostname (complete name.domain.tld)
Changed to this:

Code:
<?php
$to = '[email protected]';
$from = '[email protected]';
$fromname = '[email protected]';
$subject = 'HTML Email';
$headers = "Date: ".date('r')."\n";
$headers .= "Return-Path: ".$from."\n";
$headers .= "From: ".$fromname."\n";
$headers .= "Message-ID: <".md5(uniqid(time()))."@anotherdomain.xxx>\n";
$headers .= "X-Priority: 3\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= 'Content-Type: text/html; charset="utf-8"'."\n";
$body ='
HTML Email Body
';
mail($to, $subject, $body, $headers);
?>

With this arrive from [email protected] without any refer to server hostname.

Regards
 
As you may understand, it's not the "from" the issue rather than the things you can notice only in the detailed header of the email.. Envelope-from, return-path are some of them..
Did you check those also?
And have you mod_ruid2 configured on your server?
 
I now noticed, you mean the sender in mail haders, i didnt noticed that till now and never had any issue with that... but maybe someone else can point you to a right solution.

Regards
 
I now noticed, you mean the sender in mail haders, i didnt noticed that till now and never had any issue with that... but maybe someone else can point you to a right solution.

Regards

That's my hope.. Maybe someone with apache experience, and suEXEC / ruid2 enabled..

Thank you for all your effort..
 
I know that this is correct and that's the way it should be .. But when you enable mod_ruid2 this parameter seems to make no difference at all..

Find below a small php script (save it as email.php and run it from a virtual host user account) and change from / to email addresses / names as you wish..

What if you try to run the script in a shell from name of root user and non-root user?
 
Well, I did run up this post a couple of times the last days I am trying to sort this out, but didn't try it, as I thought it has nothing to do with mod_ruid2 / suEXEC ...

I tried now, and it worked as a charm! :)


Thank you a lot for pointing that out!

Have a great weekend!
 
By default you've got in /etc/exim.conf this line:

Code:
trusted_users = mail:majordomo:apache:diradmin

So they are the only who are trusted.
 
Back
Top