Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Dec 08, 2009 7:12 pm 
Offline
Senior Newbie
User avatar

Joined: Mon Nov 30, 2009 8:33 pm
Posts: 7
Website: http://kornrunner.net/
Location: Belgrade, Serbia
I need some help here. I've set up postfix as a null client, and searched whole email/smtp forum, but couldn't find any solution.

Code:
$ posconf -n

says:
Code:
inet_interfaces = loopback-only
mydestination = localhost.mydomainhere.com, localhost
mydomain = mydomainhere.com
myhostname = hostname.mydomainhere.com
mynetworks_style = host
myorigin = $mydomain


I have also set up apache & php, and I have name based virtual hosts (few sites). All domains have Google Apps on & MX's set up. Problem is that all mail that I send, no matter the domain, has

Code:
From: http@mydomainhere.com


I would like to set up postfix / php / apache to send mail with From: that states host from which it's sent.

So, if mail is sent from some php script on domain1.com i'd like it to show http@domain1.com, not http@mydomainhere.com.

Setting sendmail_from didn't help (via ini_set, or via .htaccess php_value). What am I missing in my configuration?


Last edited by kornrunner on Wed Dec 09, 2009 3:44 am, edited 2 times in total.

Top
   
 Post subject:
PostPosted: Tue Dec 08, 2009 7:31 pm 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
In PHP's mail() function you can set additional headers "From: your@address.com\r\n", that's the most straightforward way.

Otherwise, there is the PHP.ini option sendmail_from, but afaik that is for Windows only, I don't know if it is taken into consideration on Linux.


Top
   
 Post subject:
PostPosted: Tue Dec 08, 2009 7:49 pm 
Offline
Senior Newbie
User avatar

Joined: Mon Nov 30, 2009 8:33 pm
Posts: 7
Website: http://kornrunner.net/
Location: Belgrade, Serbia
Thanks for the reply! As I've said, I've tried with sendmail_from, but as you have said - that option is ignored on Linux systems.

I'd rather try to set this up automagically than to edit all mailer scripts... And I believe there is a way to do it. I'm not tied to postfix - I'm open to any solution that would get this working.


Top
   
 Post subject:
PostPosted: Tue Dec 08, 2009 8:19 pm 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
I just checked the docs, there's mail.force_extra_parameters php.ini directive which acts as fifth parameter of mail(). So

mail.force_extra_parameters = "-f your@name.com"

But you have to set that in php.ini, afaik you can't set it via .htaccess.


Top
   
PostPosted: Tue Dec 08, 2009 8:51 pm 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
kornrunner wrote:
I would like to set up postfix / php / apache to send mail with From: that states host from which it's sent.

The default value for "myorigin" is $myhostname. If you drop the "myorigin = $mydomain" line from main.cf I think you will get the behavior you are looking for.

http://www.postfix.org/postconf.5.html#myorigin


Top
   
 Post subject:
PostPosted: Wed Dec 09, 2009 3:40 am 
Offline
Senior Newbie
User avatar

Joined: Mon Nov 30, 2009 8:33 pm
Posts: 7
Website: http://kornrunner.net/
Location: Belgrade, Serbia
Thanks!

Removing myorigin from main.cf resulted in all mail to be sent from @myhostname instead of @mydomain, but setting

Code:
php_value mail.force_extra_parameters "-f http@domain.com"


in httpd-vhosts.conf file did the trick! :) And it's cool it's that way (though it feels like a hack to me), since I'll be setting it up for every new domain that way (unlesss I find a better solution).


Top
   
 Post subject:
PostPosted: Wed Dec 09, 2009 3:56 am 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
kornrunner wrote:
And it's cool it's that way (though it feels like a hack to me), since I'll be setting it up for every new domain that way (unlesss I find a better solution).


It's not really a hack. It is expected from PHP scripts to set the From: header manually through mail(). Every decent CMS or applications does that and has configuration where you can set it.

The alternative is to force it with the above setting in php.ini.

But Stever is onto something as well, if you check the link you'll see you can set the alias database and rewrite php_user@yourdomain.com to whatever@anywhere.com.

See, thing is that PHP sends mail by calling sendmail, and sendmail takes -f parameter to specify envelope sender address (which is what you need). Sendmail is basically a MUA while Postfix is MTA, it actually connects to it via port 25 @ localhost.

So conceptually and philosophically, it is the MUA's responsibility to set the envelope from address, thatis application's (PHP). MTA address rewrite would then be a "hack", if observed from the standpoint of separation of concerns.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group