How to use smtp function in php with authentication
My code is as given below. I would like to know how to use smtp function in php with authentication in contact form. If I use hotmail id I am not able to recive the inquiry but it works fine for gmail id. It would be great if someone help in me editing my code noted below
;
$email = $_POST['email'>;
$phone = $_POST['phone'>;
$message = $_POST['message'>;
$formcontent=" Name: $name \n Email: $email \n Phone: $phone \n Message: $message";
$to = "abc@hotmail.com";
$subject = "Contact Form";
$mailheader = "From: $name \r\n";
mail($to, $subject, $formcontent, $mailheader) or die("Error!");
echo "
Thank You $name
We will be in touch as soon as possible.
"; echo "Go to Home Page
"; ?>-
Hello, It's likely the issue is that Hotmail isn't accepting the message because the form you referenced doesn't use SMTP authentication (it looks to use the PHP mail function). Your web hosting provider could review the Exim logs to confirm if that's the case. We don't offer help with coding, but you may want to check with a website such as StackOverflow for help developing a PHP form that uses SMTP authentication. EX: Need SMTP authentication in my PHP form? Thank you. 0 -
By far the best way to fix this is what cPanelMichael instructed you to do in the previous post. If you want to try something that is a lot easier (but is not guaranteed to work with Hotmail - you will have to experiment) Add the fifth parameter to your mail() line something like[php]mail($to, $subject, $formcontent, $mailheader, "-f you@yourdomain.com") or die("Error!");[/php] or you could try [php]mail($to, $subject, $formcontent, $mailheader, "-f" .$email) or die("Error!");[/php] I think you will get the best results by using a -f parameter that matches the same domain on the server that is executing the mail() function. See the PHP manual for full details PHP: mail - Manual 0 -
By far the best way to fix this is what cPanelMichael instructed you to do in the previous post. If you want to try something that is a lot easier (but is not guaranteed to work with Hotmail - you will have to experiment) Add the fifth parameter to your mail() line something like[php]mail($to, $subject, $formcontent, $mailheader, "-f you@yourdomain.com") or die("Error!");[/php] or you could try [php]mail($to, $subject, $formcontent, $mailheader, "-f" .$email) or die("Error!");[/php] I think you will get the best results by using a -f parameter that matches the same domain on the server that is executing the mail() function. See the PHP manual for full details
0 -
One more query regarding Contact form : When I receive the contact form inquiries on my mail id, It shows as removed and I can't directly reply to the sender. See the attached screenshot. Can anyone help me out through which I can avoid the above situation and get the sender email id in place of removed so that I can directly reply. ** I had changed $mailheader = "From: $name \r\n"; to "From: $email \r\n"; but then I can't receive inquiry from yahoo users. :( 0 -
[QUOTE="Add the fifth parameter to your mail() line something like[php]mail($to, $subject, $formcontent, $mailheader, "-f you@yourdomain.com") or die("Error!");[/php] or you could try [php]mail($to, $subject, $formcontent, $mailheader, "-f" .$email) or die("Error!");[/php] I think you will get the best results by using a -f parameter that matches the same domain on the server that is executing the mail() function.
But I am not able to receive inquiries from mobile, i0 -
Hello, Generally, you're going to want to use SMTP authentication instead of the PHP mail function to avoid the problems you have reported. Note you will likely receive more user-feedback on how to create or modify the PHP coding on a website such as StackOverflow. Thank you. 0
Please sign in to leave a comment.
Comments
6 comments