Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-18-2013, 10:54 PM   PM User | #1
Raphael
New Coder

 
Join Date: Mar 2009
Posts: 70
Thanks: 3
Thanked 3 Times in 3 Posts
Raphael is an unknown quantity at this point
Linux email configuration - multiple domains

We have a webserver that hosts 2 domains.

PHP version: 5.3.3-7+squeeze14

Apache info:
Server version: Apache/2.2.16 (Debian)
Server built: Nov 30 2012 08:33:45

These are configured in these directories:

/etc/apache2/sites-available
/etc/apache2/sites-enabled
/etc/apache2/ports.conf

Everything responds correctly in the web browser, except we're having problems with sending email.

I have exim4 set up for email but I'm not sure if I have it configured correctly. Before I set up the 2nd domain (www.domain2.us), email was working fine from the original domain (www.domain1.com). After I set up domain2.us, email stopped working for domain1.com (& didn't work for domain2.us).

I tried dpkg-reconfigure exim4-config several times and eventually got domain2.us and domain1.com to be able to send email from a simple test script that looks like this:

domain1.com:
PHP Code:
<?php
$headers 
'From: [B]webmaster@domain1.com[/B]' "\r\n" .
    
'Reply-To: [B]webmaster@domain1.com[/B]' "\r\n" .
    
'X-Mailer: PHP/' phpversion();

// The message
$message "[B]domain1.com[/B]\nLine 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message wordwrap($message70"\r\n");

// Send
$suc mail('myemail@hotmail.com''My Subject'$message);

echo 
'[' $suc ']';
?>
domain2.us:
PHP Code:
<?php
$headers 
'From: [B]webmaster@domain2.us[/B]' "\r\n" .
    
'Reply-To: [B]webmaster@domain2.us[/B]' "\r\n" .
    
'X-Mailer: PHP/' phpversion();

// The message
$message "[B]domain2.us[/B]\nLine 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message wordwrap($message70"\r\n");

// Send
$suc mail('myemail@hotmail.com''My Subject'$message);

echo 
'[' $suc ']';
?>

However, when the emails come in the sender for domain1.com shows up as:

webmaster@domain1

emails from domain2.us show up as:

www-data@domain1

How can I get the ones from domain2.us too show up as being from webmaster@domain2 instead of www-data@domain1?

Thanks!
Raphael is offline   Reply With Quote
Old 02-19-2013, 12:09 AM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
You need to be passing your custom headers in the mail() function's 4th argument:
PHP Code:
mail('myemail@hotmail.com''My Subject'$message$headers); 
And make sure you remove the [B] tags you have in the headers currently.

Alternatively, you can create/use an SMTP account for each domain to send email through so it will always be the correct domain & username.
Inigoesdr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:13 PM.


Advertisement
Log in to turn off these ads.