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 robert@kaydoo.com 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 = "robert@yahoo.com"; $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 Quote 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. Quote 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 = 'dude@yahoo.com'; $subject = 'Hello!'; $message = 'Hello from your friendly PHP script'; $headers = 'From: robert@home.com'; echo "This sends an email to $to"; echo '<br>'; if(mail($to,$subject,$message,$headers)) { echo "Message successfully sent!"; } else { echo "Message delivery failed..."; } ?> Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/71927-help-with-mail/#findComment-363160 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.