IIS 7 and Above
SMTP and PHP can only send mail to server's address
Last post Apr 13, 2011 04:21 PM by eye-eye-es
Apr 05, 2011 07:12 PM|eye-eye-es|LINK
I am trying to convince IIS to send emails to addresses that are not @SERVER_NAME
For instance the code below will throw an error, but if I replace the address with address@SEVER_NAME it will get sent to the mailroot\drop folder.
$to = 'email@example.com';
$subject = 'Php mail test';
$message = 'This is an email.';
$headers = 'From: webmaster@SERVER_NAME' . PHP_EOL;
mail($to, $subject, $message, $headers);
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1
Unable to relay for firstname.lastname@example.org
Unable to relay
Apr 06, 2011 12:44 PM|sbradk|LINK
You need to use the IIS6.0 management console to manage the MS SMTP Service. It should be set by default to allow relay for 127.0.0.1 though.
Apr 06, 2011 01:31 PM|eye-eye-es|LINK
Apr 06, 2011 03:51 PM|sbradk|LINK
It doesn't matter. You still need to use the legacy interface to manage IIS SMTP.
Apr 07, 2011 01:52 AM|topspy|LINK
Also, if you're under a localhost environment and local SMTP it won't send out the email to external email address.
Apr 07, 2011 01:56 AM|crouchie2004|LINK
Are you a GoDaddy e-mail address user by any chance?
Apr 07, 2011 01:27 PM|sbradk|LINK
That's not correct. The local SMTP service can relay to external email addresses.
Apr 07, 2011 07:16 PM|eye-eye-es|LINK
Apr 07, 2011 11:40 PM|sbradk|LINK
No. When you install the SMTP services on IIS7 it will automatically install the IIS6 Management Console for you. You'll see it under Adminstrative Tools.
Apr 08, 2011 07:31 AM|KristoferG|LINK
IIS can relay to local addresses, without any special relay setting. But to be able to relay to external addresses, you need to allow the client (in this case the server itself) to relay. This explains the behavior you see.
To configure this, have a look at this page:
Is it not possible for you to follow it? If so, where does it fail?
Apr 12, 2011 04:17 PM|eye-eye-es|LINK
Well, I have no idea what happened but I started getting a new message:
Failed to connect to mailserver at "localhost" port 25,
verify your "SMTP" and "smtp_port" setting in php.ini
The "Simple Mail Transfer Protocol (SMTP)" service is definitely running, and I added 127.0.0.1 to the relay so I'm not sure why it can't connect, I had a SysAdmin make sure nothing was blocking port 25 on the box so I'm clueless...
Can I just point php.ini to an exchange server and avoid the whole mess with the local smtp service?
Apr 12, 2011 04:54 PM|KristoferG|LINK
If you can reach the exchange server from the webserver, and can use it (authenticate or something), you should be fine to set it to use exchange server instead.
Apr 13, 2011 04:21 PM|eye-eye-es|LINK
After changing by server name from "localhost' to "MY_SERVER_NAME" in the php.ini it is now working
almost as expected...
[mail function ]
SMTP = "MY_SERVER_NAME"
smtp_port = 25
sendmail_from = "email@example.com"
After trying out my mail function I sent a few emails, the only emails that left the mailroot\Queue folder where messages addressed to *@gmail.com addresses.
Diagnostic-Code: smtp;50 Access Denied - Invalid HELO Name
(See RFC2821 22.214.171.124)