RobertSubnet Posted October 5, 2007 Share Posted October 5, 2007 Greetings all. I am having a problem using mail() and was hoping some kind soul could give me some feedback as to what I am doing wrong. When executing the script, IE just hangs. No error messages, the first part of the script doesn't even run. IE just times out with a blank page. None of my other scripts do this. I am using a mail server on my local network which I have confirmed works, using Outlook Express to send test messages to Yahoo. SMTP port 80 PHP v.5.2.3 INI settings: sendmail_from [email protected] sendmail_path no value SMTP localhost (IIS and the mail server are on the same machine 192.168.1.204) smtp_port 80 The code I am using: <?php $to = "[email protected]"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; echo "this script will attempt to send an e-mail to $to"; if (mail($to, $subject, $body)) { echo"Message successfully sent!"; } else { echo"Message delivery failed..."; } ?> Thank you for taking the time to look this over. ~Robert Link to comment https://forums.phpfreaks.com/topic/71927-help-with-mail/ Share on other sites More sharing options...
RobertSubnet Posted October 5, 2007 Author Share Posted October 5, 2007 Sorry for the bump, still hoping to get some help. Link to comment https://forums.phpfreaks.com/topic/71927-help-with-mail/#findComment-362936 Share on other sites More sharing options...
RobertSubnet Posted October 6, 2007 Author Share Posted October 6, 2007 Well I finally got it figured out. It seems that not having the From header is what caused the problem. Below is the code that works: <?php $to = '[email protected]'; $subject = 'Hello!'; $message = 'Hello from your friendly PHP script'; $headers = 'From: [email protected]'; echo "This sends an email to $to"; echo '<br>'; if(mail($to,$subject,$message,$headers)) { echo "Message successfully sent!"; } else { echo "Message delivery failed..."; } ?> Link to comment https://forums.phpfreaks.com/topic/71927-help-with-mail/#findComment-363159 Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 topic solved plz Link to comment https://forums.phpfreaks.com/topic/71927-help-with-mail/#findComment-363160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.