E-mails sent from PHP are always from [email protected]

BlueCola

Verified User
Joined
Jan 12, 2012
Messages
75
Hi,

I just set-up a new server for a website which will cause a lot of traffic/server load. I tested a few thing and everything looks fine, except for one thing:

When I sent an e-mail from PHP and I set the 'from' header to [email protected] the e-mail is received as 'From: <[email protected]> on behalf of <[email protected]>'. The e-mail source looks like this:

Code:
Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Sun, 12 Jan 2014 16:02:16 +0100
Received: from mx.ourmxserver.com ([IP-ADRESS])
	by receiving.serverhostname.com with smtp (Exim 4.76)
	(envelope-from <[email protected]>)
	id 1W2MYK-00086C-SG
	for [email protected]; Sun, 12 Jan 2014 16:02:16 +0100
Received: (qmail 22091 invoked from network); 12 Jan 2014 15:02:16 -0000
Received: from localhost (HELO mx.ourmxserver.com) (127.0.0.1)
  by mx.ourmxserver.com with SMTP; 12 Jan 2014 15:02:16 -0000
X-Spam-Level: *
X-Spam-Status: No, hits=-1.3 required=5.0
	tests=BAYES_00,HTML_MESSAGE,MIME_HTML_ONLY,RP_MATCHES_RCVD
X-Spam-Check-By: mx.ourmxserver.com
Received: from my-hostname.com (HELO my-hostname.com) (2a02:2308::216:3eff:fe7c:11b6)
    by mx.ourmxserver.com (qpsmtpd/0.84) with ESMTP; Sun, 12 Jan 2014 16:02:16 +0100
Received: from my-da-username by my-hostname.com with local (Exim 4.76)
	(envelope-from <[email protected]>)
	id 1W2MYJ-0007KU-Cu
	for [email protected]; Sun, 12 Jan 2014 15:02:15 +0000
To: [email protected]
Subject: =?UTF-8?Q?Nieuwe_klan?=  =?UTF-8?Q?t_bestelling_(#1624)_-_12_januari,_2014?=
X-PHP-Originating-Script: 503:class-phpmailer.php
Date: Sun, 12 Jan 2014 15:02:15 +0000
From: Bluecola <[email protected]>
Message-ID: <[email protected]>
X-Priority: 3
X-Mailer: PHPMailer 5.2.4 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=UTF-8
Sender:  <[email protected]>

As you can see the from header is correct, but the sender, received and return-path are incorrect (or at least not the e-mail adres which I want the e-mail client to say it comes from).

Code:
From: Bluecola <[email protected]>
Sender:  <[email protected]>
Received: from my-da-username by my-hostname.com with local (Exim 4.76)
	(envelope-from <[email protected]>)
	id 1W2MYJ-0007KU-Cu
	for [email protected]; Sun, 12 Jan 2014 15:02:15 +0000
Return-path: <[email protected]>

My other servers don't have this problem and after a few hours of searching where this little problem comes from I'm getting a bit grumpy. Does anyone have an idea?

Thanks in advance,
BlueCola
 
Thanks for your reply! I'm using WordPress with WooCommerce and Contact Form7, but the script here has the same result:

Code:
<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n";

mail($to, $subject, $message, $headers);
?>

As I said in my post, the same website / script works as expected (without the 'on behalf of' or having a double 'from' in an e-mail client) on my other servers.
 
Hello,

Have you tried this?
http://help.directadmin.com/item.php?id=257

It may help by letting exim know that this User is trusted and scripts sending mail from this User are allowed to override the sender value.

Also try setting the other headers as well:
Code:
Return-pathSender
because the From set does appear to "stick".. but it's the other headers that need to be set.

John
 
Back
Top