jim.davidson Posted March 23, 2009 Share Posted March 23, 2009 Could someone tell me why I'm getting this error? Any help will be appreciated! Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in Here's my code, // initialize variables $to = $email; $subject = 'Message from MyWeb Site'; // build the message $message = "From: My Site\n"; $message .= "Email: [email protected]\n\n"; $message .= "Dear $name:\n\n"; $message .= "Thank you for inquiring r\n"; $message .= "We will contact you at the time you have indicated to discuss details, answer questions and plan your\n"; $message .= "experience.\n\n\n"; $message .= "Warm Regards\n\n"; $message .= "Jim D\n"; // build additional headers $additionalHeaders = "From: My Web Site\r\n"; $additionalHeaders .= "Reply-To: [email protected]"; // send the mail if there are no errors if (!isset($error)) { $mailSent = mail($to, $subject, $message, $additionalHeaders); // check to see if sent successfully if (!$mailSent) { $error['notSent'] = 'Sorry there is a problem sending your message. Please try later.'; } else { $sent = true; } } Link to comment https://forums.phpfreaks.com/topic/150764-solved-sending-email-error/ Share on other sites More sharing options...
Yesideez Posted March 23, 2009 Share Posted March 23, 2009 Surrounding code with CODE tags helps a LOT. Link to comment https://forums.phpfreaks.com/topic/150764-solved-sending-email-error/#findComment-792086 Share on other sites More sharing options...
Mikedean Posted March 23, 2009 Share Posted March 23, 2009 I'm guessing it's $additionalHeaders = "From: My Web Site\r\n"; If you want it to display a name instead of the address then do. $additionalHeaders = "From: My Web Site <[email protected]>\r\n"; Hope this helps Link to comment https://forums.phpfreaks.com/topic/150764-solved-sending-email-error/#findComment-792093 Share on other sites More sharing options...
jim.davidson Posted March 23, 2009 Author Share Posted March 23, 2009 Mikedean, Thank you, $additionalHeaders = "From: My Web Site\r\n"; was the problem, I been staring at this for over an hour and didn't see it! Thanks again Link to comment https://forums.phpfreaks.com/topic/150764-solved-sending-email-error/#findComment-792103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.