<?php
    $user_name = $_POST["NameBox"];
    $user_contact = null;
    $user_contact=$_POST["ContactBox"];
    $comment = $_POST["msgbox"];    
    if($user_contact==null)
    {
        $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";
    mail($to,$subject,$body); 
    header("Location:http://www.masconsolidated.com/confirmation.html");
    exit;    
?>

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

Member Avatar for LastMitch

@istore221

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:

http://email.about.com/od/emailprogrammingtips/qt/Configure_PHP_to_Use_a_Local_Mail_Server_for_Sending_Mail.htm

and also read this:

http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm

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

no i want to confire my gmail account ..not local account

Member Avatar for LastMitch

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:

http://phpmailer.worxware.com/index.php?pg=examplebgmail

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

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.

Member Avatar for diafol

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:

http://www.youtube.com/watch?v=_QnfF64rA78

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.

$senderName=$_POST["name"];
$senderEmail=$_POST["mail"];
$senderPhone=$_POST["mob"];
$quantity=$_POST["quantity"];
$build=$_POST["build_time"];
$layers=$_POST["layers"];
$dimension1 =$_POST["length"];
$dimension2 =$_POST["width"];
$message=$_POST["msg"];

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.