contact form 'reply to' not working as planned [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to make emails sent via contact form on my website to appear as being sent from user's mailbox (eg. user specified his email in contact form as 'john1233#gmail.com' - i want this email to be seen as sent from him directly, with proper reply option).
I tried to modify this script on my own, with no success :( I am not very proficient with php, so any help will be much appreciated!!
Here is the script I used:
<?php
if(isset($_POST['email'])) {
$email_to = "my email";
$email_subject = "mail subject";
// validation here
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
// error messages here
$error_message = "";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .='my html code'
;
// create email headers
$headers = 'From: '.$email_from."\r\n".
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-type: text/html; charset=utf-8\r\n";
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>

It should be:
$headers = 'From: '.$email_from."\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/html; charset=utf-8\r\n" .
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();

Related

PHP xammp sendmail error: Message is missing sender's address [duplicate]

This question already has answers here:
php single and double quotes
(2 answers)
Closed 1 year ago.
I have set up the Sendmail client on my localhost xammp server running on my home pc but I am getting the following error:xx-xx-xx xx:xx:xx: Message is missing sender's address. I have gotten it to work when I use the hard code what I want to send, like so:
$msg = "hello world";
mail("example#gmail.com","My subject",$msg, 'From: admin#myEmailClient.com');
but when I try and implement my login validation script It does not work and I get the aforementioned error.
emailvalidation.php
$to = $email;
$sub = 'email verification';
$msg = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$headers = "From: admin#myEmailClient.com \r\n";
$headers = "MIME-Version: 1.0". '\r\n';
$headers = "Content-type:text/html;charset=UTF-8 ". '\r\n';
mail($to, $sub, $msg, $headers);
my email variable is set by the user if that helps, I don't think its a problem with the items being parsed because when I check my database all rows are properly filled in.
thank you for your time
edit
I think it's a problem with the r\n parts, these are the parts that enable HTML in emails. when I get rid of them it works
I'm not sure if I should delete this question because of the speed I was able to solve it but I hope this helps someone who had the same problem as I did.
here is how I solved the problem
$message = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$to = $email;
$subject = 'account validation';
$from = 'admin#myEmailClient.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
header("location: index.PHP");
}
I got the solution from here. tutorial republic

Want to send php mail() to two users at the same time using php variable [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
PHP form send email to multiple recipients
(9 answers)
Closed 5 years ago.
Am trying to use php to send email to two different users all at the same time from the user input information which i have convert into variables.
<?php
$shipperemail = mysqli_real_escape_string($con, $_REQUEST['shipperemail']);
$receiveremail = mysqli_real_escape_string($con, $_REQUEST['receiveremail']);
$receiveremail = mysqli_real_escape_string($con, $_REQUEST['receiveremail']);
$email_from = "valueHandlers#me.com";
$email_to = ".$shipperemail.";
$email_to = ".$receiveremail.";
$email_subject = "Tracking Code";
$email_message .= "Tracking Code: ".$consignmentno."\n";
$email_message .= "Sender Name: ".$shippername."\n";
$email_message .= "Receiver Name: ".$receivername."\n";
$email_message .= "Expected date of delevery: ".$shipmentexpected."\n";
$email_message .= "Comments: ".$comments."\n";
$email_message .= "for more update, folow the link Http://valuehandlers.com/track";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
but none of the variable is delvering the mail to the variables emails

my php code send empty email [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Please, this is php code that i used to send from HTML contact page, it works with out error but only i receive empty email! just the object of email i get and nothing else.
<?php
$email_address = $_POST["email"];
$tel_num = $_POST["tel"];
$first_name = $_POST["f_name"];
$last_name = $_POST["l_name"];
$text_send = $_POST["email_text"];
$to_com = "myemal#gmail.com" ;
$subject = " New eMail" ;
mail ($to_com, $subject, $text_send, " From: " . $email_address . $tel_num . $first_name .$last_name );
echo "Your Massage has been sent" ;
?>
So please i need some help?
Please look at this example from php.net
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
the line endings in the header (\r\n) are very important

mail() function doesn't not send infomation to my email [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
Here is my code:
<?php
header('Content-type: text/plain; charset=utf-8');
$to = 'example#gmail.com';
$subject = 'Message to the site';
$realname = htmlspecialchars($_POST['realname']);
$email = htmlspecialchars($_POST['email']);
$msg = htmlspecialchars($_POST['msg']);
$headers = 'From: example#gmail.com' . "\r\n" .
'Reply-To: example#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $msg, $headers) or die("Error!");
echo 'Thank you! :)';
?>
Could somebody explaing me - why this code does not work properly?
I meant that, when I click button submit, it send the email, but I could not include $msg in it and I don't know why.
Try to add :
$headers .= 'Content-type: text/html';
Add this line under $headers and than check i hope this will work for you...

A php mail function regarding the additional parameters for headers

I'm using dreamhost for my mailing.
I'm having an issue with php mail function additional headers parameters.
This code works, and the email is sent:
$to = 'myemail#gmail.com';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = "From: $name <**webmaster#example.com**>\r\n" .
"Reply-To: $name <**webmaster#example.com**>\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
but when I replace webmaster#example.com to the variable $email
$headers = "From: $name <**$email**>\r\n" .
"Reply-To: $name <**$email**>\r\n" .
'X-Mailer: PHP/' . phpversion();
The email doesn't get sent. I did do a print_r($_POST), and the elements are there. I also did another test where I typed the email: webmaster#example.com into the form, to see if it would send, and it did. So my question is, how do I remedy this issue, if a user types their email address into the form with another mailing extension, that mail will not get sent, but if the extension is #example.com, then the mail will get sent.
$name variable should be the full emailaddress:
"$name = " 'a name' email#whatever.com> "
$headers = "From: $from \r\n";
works on my servers. Add the leading < to the email addtress. This system won't display the string at all if I include it. If your form has different variables for the responders nam and email address you'll have to concatenate them to get $name in the right formate.

Categories