Giri J Posted August 18, 2009 Share Posted August 18, 2009 Hello Guys, I'm trying out on the mail function. I've created my website and added a contact form. Now I want the contact details to come to my gmail id. I've written the following code. ---------------------------------------------------------------------------------------- <?php $to = "[email protected]"; $subject = "Test My Code"; $name_field = $_POST['cName']; $email_field = $_POST['cEmail']; $from = "Contact Form"; $message = $_POST['comments']; $ph=$_POST['cPh']; $cLoc=$_POST['cLoc']; $body = "From: $name_field\n E-Mail: $email_field\n Phone: $ph\n Country: $cLoc\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body, "From: $from") ?> ---------------------------------------------------------------------------------------- When I tried the code on my local it threw a error saying some smtp problem. Later I uploaded the same code onto my server. I didn't see any errors but at the same time I didn't receive any data in my gmail inbox. I've tried searching old threads but it didn't help. Did I miss something? I don't know. Please Help. Thanks in Advance. Quote Link to comment https://forums.phpfreaks.com/topic/170885-mail-functionality/ Share on other sites More sharing options...
ignace Posted August 18, 2009 Share Posted August 18, 2009 SMTP needs to be installed. Quote Link to comment https://forums.phpfreaks.com/topic/170885-mail-functionality/#findComment-901323 Share on other sites More sharing options...
Giri J Posted August 19, 2009 Author Share Posted August 19, 2009 Hi, You mean to say I have to request the support guys to configure smtp in php config to some gmail servers or something? Please let me know. thank you Quote Link to comment https://forums.phpfreaks.com/topic/170885-mail-functionality/#findComment-901544 Share on other sites More sharing options...
trq Posted August 19, 2009 Share Posted August 19, 2009 He means to say that in order for the script to work locally you would need an smtp server installed. As for why it may not have worked on your remote server, the From header needs to be a valid email address of the domain you are sending the email from or most email services will send it straight to the trash. Quote Link to comment https://forums.phpfreaks.com/topic/170885-mail-functionality/#findComment-901661 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.