$user_name = $_POST["NameBox"];
    $user_contact = null;
    $comment = $_POST["msgbox"];    
        $user_contact = "Not provided";
    $to = "mymail@domain.com";
    $subject = "Message From Web";
    $body = "Contact name is = $user_name | Contact number is = $user_contact | user comment is = $comment";

this is my send mail code . i want to know will it work ?? i want to make sure it is correct before upload the script ..thank you.. is there any way to test it at home ..i mean the php sendmail and php.ini :( can you tell me how do i configure mail server at home :( code will be better

4 Years
Discussion Span
Last Post by Anuradha_2


is there any way to test it at home ..i mean the php sendmail and php.ini :( can you tell me how do i configure mail server at home :( code will be better

So you want to send it on your local host (home) then read this:


and also read this:


The code you provided is incomplete so read the links and get familiar with the code from the links because you need to configure it correctly in order to send it at local host(home).

Edited by LastMitch: grammer


not local account

You mention at home that means local meaning on your own computer meaning using WAMPP or EasyPHP.

i want to confire my gmail account

Read this and used that code:


Like I mention before the code you provided is incomplete there's more code involve dealing with gmail account.

Edited by LastMitch: grammer


PHPMailer is the way to go and no you cannot test sending mail script on your localhost i.e your wamp, mamp or xampp. grab some free hosting and try this script out! Simple! PHPMailer is much more secure and it would require the SMTP username and the password. Please note: the newly available servers do not support PHP mail() function. Its a security feature to stop hacker and spammers. SMTP will carry the sender's information for more security.


XAMPP comes with the Mercury Mail service. You can implement that to send from your local machine. It's a bit of a fiddle though. There are some videos on YT:


Beware - relays can be pounced upon by spammers.

Why don't you place the script in your admin area or something to see if it works on your remote server anyway? Chances are that the settings may be different and you may need to place tags like -f or similar to get it to work.

Edited by diafol

$dimension1 =$_POST["length"];
$dimension2 =$_POST["width"];

// If all values exist, send the email

 if ( $senderName && $senderEmail && $senderPhone && $message ) 
  $recipient = example . " <" . example@gmail.com . ">";
  $subject = " India Electronics Quote Form";
  $headers = "From: " . $senderName . " <" . $senderEmail . ">";
  $mailBody = 'Sender Name: ' . $senderName. "\r\n" . 'Sender Email: ' . $senderEmail . "\r\n" .'Sender Phone: '. $senderPhone . "\r\n" . 'Message: ' . $message ;
  $success = mail($recipient, $subject, $mailBody, $headers);
  echo "<p>Thanks for contacting us. We will contact you ASAP!</p>";

sending Mail using Php for live site. I have tried it for so long.its not working.

Edited by Anuradha_2

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.