Jump to content

Mail functionality


Giri J

Recommended Posts

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 = "g.mymails@gmail.com";

$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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.