Hi,

I used this coding for sending mail.It's working but there is a problem,I receive mail 2 times,then sender mail id is not displaying,It receiving in the name of webmaster that in coding ($headers = 'From: webmaster@example.com ' . "\r\n")(eg. webmaster@example.com),


I want receive mail as sender mail Id who send this mail,Please make correction in my coding and clear my doubt.................

<?php
if (isset($_POST['Submit'])){
    extract($_POST);
    $ErrNo   = 0;
    $Name    = $_POST['name'];
    $Email   = $_POST['email'];
    $Company = $_POST['company'];
    
    if ($Name == ''){
        $ErrNo  = 1;
        $Err[] = 'Please enter name.';
    }
    if ($Email == ''){
        $ErrNo  = 1;
        $Err[] = 'Please enter email id.';
    }
    if ($Company == ''){
        $ErrNo  = 1;
        $Err[] = 'Please enter company name.';
    }
    if ($ErrNo  == 0){
        if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email))
        {
           $ErrNo = 1;
           $Err[] = 'Please enter valid email address.';
        }
    }
    if ($ErrNo  == 0){

        $Phone   = trim($_POST['phoneno']);
        $Content = trim($_POST['comment']);
        $Web     = trim($_POST['website']);
        $Address = trim($_POST['address']);
        
       $from = $Email;
    $to = "user@example.com";
    $subject = "example Enquiry Mail";

    $message = 'Comments'.$Content.
	 'Phone '.$Phone.
	 'Address'. $Address;   // set the body
    echo $message;
    echo $to;
    echo $subject;
    // Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP","localhost");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', 'ValidEmailAccount@YourDomain.com');
    //$headers = 'From: [email]webmaster@example.com[/email] ' . "\r\n" .
    //'Reply-To: [email]webmaster@example.com[/email] ' . "\r\n" .
    //'X-Mailer: PHP/' . phpversion();
    mail($to,$subject, $message);	// set the body
	//$m->Cc( "someone@somewhere.fr");
	//$m->Bcc( "someoneelse@somewhere.fr");
	//$m->Priority(4) ;	// set the priority to Low
	//$m->Attach( "/home/leo/toto.gif", "image/gif" ) ;	// attach a file of type image/gif
	
	if (@mail($to, $subject, $message)) {  
 echo('<p>Mail sent successfully.</p>');  
} else {  
 echo('<p>Mail could not be sent.</p>');  
}  
       
    }
 }
?>

you should attach headers to the message to specify enc type text/html

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.