contact form showing my host address. when i got message - php

hello i have using a contact form when i get any mail from my client i saw my host name showing in mail from. like when i saw saw before open my mail there showing name who send and from where i saw there showing my host name geologicsdz#host.dramaclassesonline.com.
but in mail everything ok.
so i like to change host name where must be show from his email address
$post = (!empty($_POST)) ? true : false;
$replyto='my#email.com';
if($post)
{
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$business = stripslashes($_POST['business']);
$comments = stripslashes($_POST['comments']);
$phone = stripslashes($_POST['phone']);
$howhear = stripslashes($_POST['howhear']);
$to=$toemail.','.$replyto;
$error = '';
$headers="";
$headers.="Reply-to:$replyto\n";
$headers .= "From: $email\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers;
if(!$error)
{
$messages="<h2>From: $name has contacted Geological Solutions</h2>";
$messages.="<h4>Name: $name </h4>";
$messages.="<h4>Email: $email </h4>";
$messages.="<h4>Phone: $phone </h4>";
$messages.="<h4>How did you hear about us?: $howhear </h4>";
$messages.="<h4> Comments: $comments </h4>";
$mail = mail($to,$name,$messages,$headers);

you were in the correct path but have overwritten your headers. here is the fix for it
$headers="";
$headers.="Reply-to:$replyto\r\n";
$headers .= "From: $email\r\n";
$headers .= 'MIME-Version: 1.0';
$headers = "Content-Type: text/html; charset=iso-8859-1\r\n".$headers;

Related

how to hide reply-to header when received by mail box?

How can i hide reply to header , from mail boxes,
For example , i send a mail from test#domain.com with reply to as notification#domain.com, and receiver open the mail and click on reply, i want the receiver to see from email which is test#domain.com in reply, instead of reply to which is notification#domain.com, and also the reply will come notification#domain.com .
Any help. My code below
<?php
if(#isset($_POST['send'])){
$From = $_POST['From'];
$Subject = $_POST['Name'];
//$Message = $_POST['Message'];
$Message = "";
$Reply= "notification#domain.com";
$Emails = $_POST['Emails'];
$toname = $_POST['toname'];
$Name = $_POST['Name'];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html;charset=UTF-8\r\n";
$headers .= "Reply-To: ".$Reply."\r\n";
$headers .= "From: ".$From."\r\n";
$headers .= "Hi<br>".$toname."\r\n";
$headers .= "<br><br>Are you today? <br><br><br><br>Thanks,<br>".$Name."<br><br>
Sent from my work office\r\n";
$Emails = explode("\r\n", $_POST['Emails']);
foreach($Emails as $email) {
mail($email,$Subject,$Message,$headers);
echo "<br>Sending Email from : name:".$Name.", email: ".$From.", to name: ".$toname.", email:".$email." => was successfully sent";
//echo "<br>Sending Email To : ".$email." => Done";
}
}
?>

My server's name shows up as submitter's Reply-to email address from PHP contact Form

I'm not versed in PHP and had this form built for me. It works 95% of the time, but sometimes the reply-to email will be johnsmith#hadrian.lunarpages.com
I'm reading up a similar issue on this page, but not exactly sure what to change in my form...
<?php
if (isset($_REQUEST['btnSubmit-group'])) {
$date = $_REQUEST['date'];
$time = $_REQUEST['time'];
$count = $_REQUEST['count'];
$name = $_REQUEST['name'];
$organization = $_REQUEST['organization'];
$email = $_REQUEST['email'];
$grouptype = $_REQUEST['grouptype'];
$phone = $_REQUEST['phone'];
$upgrademus = $_REQUEST['upgrademus'];
$upgradeowo = $_REQUEST['upgradeowo'];
$comments = $_REQUEST['comments'];
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
if ($count == "" || $name == "" || $email == "" || $phone == "") {
echo "All fields are required, please fill out again. ";
} else {
$to = 'info#example.com';
$subject = "Group Tour Inquiry from $name ($date, $count people)";
$from = $to;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = nl2br("Private Tour:<br>" .
"<b>Name:</b> $name\r\n" .
"<b>Email:</b> $email \r\n" .
"<b>Phone:</b> $phone \r\n" .
"<b>Organization:</b> $organization\r\n" .
"<b>Date:</b> $date\r\n" .
"<b>Time:</b> $Time\r\n" .
"<b>Count:</b> $count\r\n" .
"<b>Include:</b> $upgrademus\r\n" .
"<b>Include:</b> $upgradeowo\r\n" .
"<b>Comments:</b> $comments\r\n" .
"");
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $name<$email> \r\n";
$headers .= "Reply-To: $email \r\n";
if (mail($to, $subject, $body, $headers)) {
echo "<div class=\"thankyou\"></div><meta http-equiv='refresh' content='0;url=http://www.example.com/private-group-tours'>";
}
}
} else {} ?>
You're trying to send e-mail's to your self FROM the person whose entering this in, essentially attempting to spoof their email, and sometimes this will(should) get blocked. more can be read here - problem with php mail 'From' header
Change:
$headers .= "From: $name<$email> \r\n";
$headers .= "Reply-To: $email \r\n";
to
$from = 'Admin#mysite.com';
$headers .= "From: $from\r\n";
$headers .= "Reply-To: $from \r\n";
and then edit that static $from variable. Then take the users email out of the BODY of the email you receive, and send them an email.

Send BCC in PHP

Need to send a BCC copy to a user2#gmail.com
Not familiar with PHP and I'm missing something.
<?php
if(empty($_POST['name2']) || empty($_POST['email2']) || empty($_POST['message2']))
{
return false;
}
$name2 = $_POST['name2'];
$email2 = $_POST['email2'];
$message2 = $_POST['message2'];
$to = 'user1#gmail.com'; // Email submissions are sent to this email
// Create email
$email_subject = "Message from Website;
$email_body = "You have received a new message. \n\n".
"Name2: $name2 \nEmail2: $email2 \nMessage2: $message2 \n";
$headers = "From: user1#gmail.com\n";
$headers .= "Reply-To: $email2";
$headers .= "Bcc: user2#gmail.com" . "\r\n";
mail($to,$email_subject,$email_body,$headers); // Post message
return true;
?>
at the end of any $header line fix that end with "\r\n"
$headers = "From: user1#gmail.com\r\n";
$headers .= "Reply-To: $email2\r\n";
$headers .= "Bcc: user2#gmail.com\r\n";
try now

Php email send copy to sender

I have a contact form and I am using the below PHP Script to get emails from my contact form. I want to send a copy of the same email to the sender email also. Can anyone help me?. Thank you!
<?php
$errors = '';
$myemail = 'chocolatehills_adventurepark#yahoo.com, chocolatehills88#yahoo.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['subject']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Message from: $name";
$email_body = "New message received. ".
" Here are the details:\n \n NAME: $name \n
SUBJECT: $subject \n
EMAIL ADD: $email_address \n
MESSAGE: $message";
$headers = "From: $email_address\n";
//$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-us.php');
}
?>
You can use cc n header
$headers .= 'Cc: somebody#domain.com' . "\r\n";
More idea
http://php.net/manual/en/function.mail.php
Examples of using CC and BCC.
Example #4 Sending HTML email
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
You can also try to add another mail function like this
mail($email_address,$email_subject,$email_body,$headers);

PHP mail function ignoring additional headers

I'm trying to send a mail using the php mail() function
but for some reason I don't get, additional headers are ignored.
This is my code:
$errors = '';
$myemail = 'my#email.com';
$myemail_bcc = 'my_bbc#email.com';
if(empty($_POST['nome']) || empty($_POST['email']))
{
$errors .= "Error: You must fill Name and Email fields";
}
$name = $_POST['nome'];
$email_address = $_POST['email'];
$telefono = $_POST['telefono'];
$message = $_POST['messaggio'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "<br />Error: You must use a valid email address";
}
// spediamo la mail
if( empty($errors))
{
$to = $myemail;
$email_subject = "New Request from: $name";
$email_body = "User data:.\n\n";
$email_body .= "Nome: $name \nEmail: $email_address \nTelefono: $telefono \n";
$email_body .= "Messaggio: \n$message";
$headers = "From: John Smith <$myemail>\r\n";
$headers .= "Reply-To: $name <$email_address>\r\n";
$headers .= "Bcc: $myemail_bcc";
mail($to,$email_subject,$email_body,$headers);
}
I've tried to vary the way I declare headers without names, just with emails:
$headers = "From: $myemail \r\n";
$headers .= "Reply-To: $email_address\r\n";
$headers .= "Bcc: $myemail_bcc";
and even just on one line
$headers = "From: $myemail\r\nReply-To: $name <$email_address>\r\nBcc: $myemail_bcc";
But in no case the mail is sento to the Bcc address, and the "reply" function in client email does not use the Reply-to address.
where am I wrong?

Categories