PHP Mail() not working on remote server
Posted
by
Amaerth
on Stack Overflow
See other posts from Stack Overflow
or by Amaerth
Published on 2012-09-22T21:04:19Z
Indexed on
2012/09/22
21:37 UTC
Read the original article
Hit count: 156
I am developing an application and have been testing the mail() function in PHP. The following works just fine on my local machine to send emails to myself, but as soon as I try to send it from the testing environment to my local machine, it silently fails.
I will still get the "Mail Sent" message, but no message is sent. I turned on the mail logging in the php.ini file, but even that doesn't seem to be populated after I refresh the page.
Again, the .php files and php.ini files are identical in both environments. Port 25 has been opened on the testing environment, and we are using a Microsoft Exchange server.
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
SMTP area of the php.ini file:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = exhange.server.org
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
© Stack Overflow or respective owner