November 6, 2012

PHP email issue

Question by user1802398

I’ve a HTML signup form with php. After a successfully submit it sends a confirmation email to the user email address.

Well, when user see his/her email it’s shown as:

Yoursite.comr@mediaplan.ovh.net

But I didn’t add the @mediaplan.ovh.net part to the email address. Why it’s showing in this address. @mediaplan.ovh.net? and how do i remove it?

php email code:

$to = "$email";                     
$subject = "Signup | Verification";
$message = "Congratulation $f_name $l_name you have been successfully registered. 
Please click the link to active your account.rn";
$message .= "http://www.maaks.fr/hotel/verify.php?email=$email&hash=$hashrn";

$from = "Yoursite.com";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-rype: text/html; charset=iso-8859-1rn";
$headers .= "Content-Transfer-Encoding; 7bitrn";
$headers = "From:" . $from . "rn";

$mailsent = mail($to,$subject,$message,$headers); 

Answer by Starx

First, You are missing a slash in your from header part.

$headers = "From:" . $from . "rn";
                          //  ^ Here

Change From headers while sending the mail

$from = "WebsiteName <Your@mail.com>";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-rype: text/html; charset=iso-8859-1rn";
$headers .= "Content-Transfer-Encoding; 7bitrn";
$headers = "From: " . $from . "rn";

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!