email from webserver not reaching mx server

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
tomato
Forum Newbie
Posts: 2
Joined: Thu Apr 09, 2009 9:54 am

email from webserver not reaching mx server

Post by tomato »

I have come across a problem that I though maybe some of you had hit in the past because the setup is pretty common - a webserver sending email to an email address within the domain, but the email server is actually a different physical device (defined by the MX record).

To give an actual example, let's say the domain name is tomato.com. I have a process on the webserver at http://www.tomato.com which sends an email to info@tomato.com. That mailbox lives on an Exchange Server in a completely different location to the webserver.

I send it From webmaster@tomato.com. This address does not actually exist within the webserver - but then none do. In addition to sending it To info@tomato.com, I also bcc the email to another address (bcccopy@anotheraddress.com) on completely different domain.

What happens is that the email never reaches info@tomato.com but it does get to bcccopy@anotheraddress.com, showing that the Swift code actually sends the email out.

I have tried all sorts of things like creating the sending address on the webserver, and checked with the receiving
Exchange Server IT people to see if any filtering might be taking the email but no luck.


My code looks like this and it is Swift 3.3.3 :

Code: Select all

 
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
 
 
 
//Create the message
$message =& new Swift_Message("Message from tomato website");
$message->attach(new Swift_Message_Part($textmessage));
$message->attach(new Swift_Message_Part($htmlmessage, "text/html"));
 
$recipients =& new Swift_RecipientList();
 
$recipients->addTo("info@tomato.com"); 
$recipients->addBcc("bcccopy@anotheraddress.com"); 
 
 
//Now check if Swift actually sends it
if ($swift->send($message, $recipients, new Swift_Address("webmaster@tomato.com", "Webmaster"))) echo "OK "; else echo "Failed";
 
 
 
Any suggestions would be appreciated
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: email from webserver not reaching mx server

Post by Chris Corbyn »

Sounds like the SMTP server your sending from (localhost) has been incorrectly configured to handle emails sent to @tomato.com as locally delivered mail. In other words, somebody has told the SMTP software that it should treat emails for tomato.com as local (write them to the mailbox on disk instead of sending them).

What SMTP software do you use? Look for a setting along the lines of "local_domain" or "local_domains".
tomato
Forum Newbie
Posts: 2
Joined: Thu Apr 09, 2009 9:54 am

Re: email from webserver not reaching mx server

Post by tomato »

I've checked with my hosting company and they assure me that no emails are handled via local delivery, all addresses are correctly resolved, so I'm kind of stumpted.

I've modified my Swift settings to use a different (remote) SMTP server and everything works fine, but would prefer to use the local one if I could.
Post Reply