HTML Form data via PHP - php

I am completely new to PHP scripts and have put together the following code, but I would like the email received to show it is sent from the email field in the HTML form rather than the current "The Tranquility Zone Website [www.tranquilityzone.co.uk#linweb.ahost.me]". Please can you advise what I should change. Many thanks.
<?
$msg .= "Name:\t $_POST[name]\n";
$msg .= "E-mail:\t $_POST[email]\n";
$msg .= "Telephone:\t $_POST[telephone]\n";
$msg .= "Subject:\t $_POST[subject]\n";
$msg .= "Message:\t $_POST[message]\n";
$to = "jenny#tranquilityzone.co.uk";
$subject = "Website feedback message";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
$mailheaders = "From: The Tranquility Zone Website <www.tranquilityzone.co.uk>\n";
$mailherders .= "Reply to: $_POST[sender_email]\n";
header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );
#mail ($to, $subject, $msg, $mailheaders);
?>

Change your code to this:
<?php
$msg .= "Name:\t ".$_POST['name']."\n";
$msg .= "E-mail:\t ".$_POST['email']."\n";
$msg .= "Telephone:\t ".$_POST['telephone']."\n";
$msg .= "Subject:\t ".$_POST['subject']."\n";
$msg .= "Message:\t ".$_POST['message']."\n";
$to = "jenny#tranquilityzone.co.uk";
$subject = "Website feedback message";
$headers = 'From: '.$_POST['email']."\r\n".'Reply-To: '.$_POST['email']."\r\n" .
$mailheaders = "From: ".$_POST['email']."\n";
$mailheaders .= "Reply to: ".$_POST['email']."\n";
header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );
#mail ($to, $subject, $msg, $mailheaders);
?>

$mailheaders = "From: $_POST[sender_email]\n";
$mailheaders .= "Reply-to: $_POST[sender_email]\n";
or
$mailheaders = "From: $_POST[email]\n";

Looks like you have a mispelling in your 2nd mailheaders (mailherders) variable
Try this:
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
$mailheaders = "From: The Tranquility Zone Website <www.tranquilityzone.co.uk>\n";
$mailheaders .= "Reply-to: $_POST[sender_email]\n";
MY DISCLAIMER: I don't condone this type of activity as it looks very shady when you get emails from someone other than the true sender. And yes you could be blacklisted for this.

Related

Send HTML Email using PHP - Not working when using email.2015#gmail.com?

I am using this basic php code to send out a html email.
When i use email#email.com as a to address the script works.
However, when i try to use email.2015#gmail.com the script says:
Parse error: syntax error, unexpected '#' in /home/u925912002/public_html/send_email.php on line 3
My code:
<?php
$to = ‘email.2015#gmail.com’;
$subject = 'I need to show html';
$from ='example#example.com';
$body = '<p style=color:red;>This text should be red</p>';
ini_set("sendmail_from", $from);
$headers = "From: " . $from . "\r\nReply-To: " . $from . "";
$headers .= "Content-type: text/html\r\n";
if (mail($to, $subject, $body, $headers)) {
echo("<p>Sent</p>");
} else {
echo("<p>Error...</p>");
}
?>
please can someone show me what i'm doing wrong. thanks
For your question recently closed: https://stackoverflow.com/questions/34106770/send-email-using-php-from-address-not-working
Try this:
$headers .= "From: Your Name <$from>\r\n";
and you can also add the 5th mail parameter:
mail($to, $subject, $body, $headers, '-finfo#userforum.com').
Works for me with these headers:
$from = "$name <$email>\r\n";
$to = "$username <$useremail>\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
you are using Apostrophe(‘) instead of quotes(')
try this -
$to = 'email.2015#gmail.com';
instead of this -
$to = ‘email.2015#gmail.com’;

"From" and "Reply-to" not woking in my PHP Contact form

I set up a simple php contact form. It is working so far, I get the emails, that is not the issue. The only thing that is not working, is the "From" and "Reply-To" field. The email I receive is from www-data#hostname.com and it also replies to that address. I don't know what I might have overlooked :(
<?php
$vorname = $_POST['vorname'];
$nachname = $_POST['nachname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$club = $_POST['club'];
$handicap = $_POST['handicap'];
$spieler = $_POST['spieler'];
$bemerkungen = $_POST['bemerkungen'];
$from = 'Von: Kontaktformular';
$to = 'edited for this question';
$subject = 'Anmeldung';
$body = "Von: $vorname $nachname\n E-Mail: $email\n Telefon: $phone\n Club: $club\n Handicap: $handicap\n Spieler: $spieler\n Bemerkung: $bemerkungen ";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: $email" . "\r\n" .
"Reply-To: $email" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
if(!isset($_POST['submit'])) {
if (mail ($to, $subject, $body, $from)) {
header("Location: edited.html");
} else {
header("Location: edited.html");
}
}
?>
Thanks for any hint!
Looks like $headers is not being used in your mail function.

Reply to won't work on php form submitting to itself

I can't get the reply to function to work on a contact form that submits to itself.
The BCC is working fine. Any help is appreciated.
$to = 'email#email.com';
$subject = ''.$_POST['emailsubject'].'';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1';
$headers .= 'Reply-To: '.$_POST['email'].'';
'X-Mailer: PHP/' . phpversion();
$headers .= 'Bcc: email#email.com' . "\r\n";
mail($to, $subject, $msg, $headers); $sendMessage = true; unset($_POST); } } ?> <?php if($invalidCaptcha) { ?>
<?php
$from_add = "test#gmail.com";
$to_add = "email#email.com";
$subject = "Test Msg";
$message="test msg.";
$headers = "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";
if(mail($to_add,$subject,$message,$headers))
{
$msg = "Mail sent OK";
}
else
{
$msg = "Error sending email!";
}
?>

PHP mail, from field

Please help. When I send email from my contact from, the sender is shown as 'From: (name of web host) on behalf of (visitor email)' - how do I remove it so it only shows the visitor's email.
I'm using shared hosting, so not sure if it's a problem on their server setting.
The codes I've used are below:
//send the email
$to = $your_email;
$subject = $visitorMessageSubject;
$from = $visitorEmail ;
$body = "Test \n\n".
$headers = "From: " .$visitorEmail . PHP_EOL;
$headers .= "Reply-To: $from" . PHP_EOL;
$headers .= "Return-Path: $from" . PHP_EOL;
$headers .= "X-Mailer: PHP/" . phpversion();
mail( $to, $subject, $body, $headers, "-f $from");
Thanks in advance.

Contact php mail page, only sending blank emails.

I am having problems with this contact page, emails are being sent fine but are blank! I cant seem to find a solution. I would of thought $_POST would need to be added, however, the web hosting companies says it is not necessary in this php script Thankyou for your time and help. Code snippet below.
<?php
$EmailFrom = "sales#ibdengland.co.uk";
$EmailTo = "kent.collins.uk#gmail.com";
$Subject = "online form";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Message = Trim(stripslashes($_POST['Description of project']));
// validation
$validationOK=true;
if (!$validationOK) {
echo "please check your details";
header("Location: http://www.ibdengland.co.uk/thankyou.html");
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Description of project: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"1;URL=thankyou.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"1;URL=thankyou.html\">";
}
?>
You forgot to add the headers.
Example:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: '. $EmailFrom . "\r\n" .
'X-Mailer: PHP/' . phpversion();
Try changing:
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
To:
$success = mail($EmailTo, $Subject, $Body, "From: <".$EmailFrom.">");
you have not use any header.
take help from here. and use it. I think it will help you.
post header like below
$headers = 'From:'.$EmailFrom . "\r\n" .
'Reply-To: '.$EmailFrom . "\r\n" .
'X-Mailer: PHP/' . phpversion();
then replace below
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
with the below code
$success = mail($EmailTo, $Subject, $Body, $headers);
plz try this one. and inform me if this work or not.

Categories