Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Whenever I send mail via Exim, even if I set a from field, it always says the e-mail is from: apache@server.mydomain.com. Is there any way to make the from field work or at least change the default from address? Thanks.

share|improve this question
    
How are you constructing the email - PHP, Python? Can you include a snippet of the code? –  Dan Carley Jun 26 '09 at 15:47
    
I'm constructing it with PHP with this class: pastebin.com/m4752fc3e –  John Jun 26 '09 at 16:11
add comment

2 Answers

up vote 1 down vote accepted

Okay, looking at the class you've linked to - you should already be setting the From: header which gets you half way there. Chances are that you're seeing the emails coming through look something like this:

From: <senderofchoice@example.com>
Sender: <apache@example.com>
Return-path: <apache@example.com>

Which isn't great. It looks confusing to a lot of people and Outlook users also helpfully see such messages tagged as "Apparently From".

This is caused by Exim not permitting Apache (as a system account) from "spoofing" the From address. You can see in line 39 of that class that sendmail is called (the Sendmail binary is symlinked to Exim for historical reasons) something like so:

sendmail -f $fromEmail

This tells Exim to specify the envelope sender address which is by default restricted to UID 0. You can read the intricate details about this from the -f section of the Exim man page. In short can change this by permitting Apache to modify the envelope sender in exim.conf:

trusted_users = apache
share|improve this answer
    
Thank you so much! –  John Jun 26 '09 at 16:33
    
No problem. Of course you should be careful of the address that is set, so that users (ie. from web forms) can't forge their own messages and generate backscatter. Or that you might contravene an SPF rule. But you get the idea.. –  Dan Carley Jun 26 '09 at 16:41
add comment

You want to make sure that the qualify_domain option is set near the top of exim4.conf.

share|improve this answer
    
That helped a little, but still didn't solve my problem. Now the e-mail says it is from apache@mydomain.com, not whatever-i-set@mydomain.com –  John Jun 26 '09 at 16:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.