Mail Send Successful but not Recive in My inbox or spam - php

I am sending mail from PHP mail function and it gives me successful message but mail is not reviving in the email. I have done my gmail POP3/SMTP/IMAP settings to my OS (Ubuntu). This is my code:
$name = "ali";
$email ="hello";
$message = "adasdasfasf";
$from = 'From: from#gmail.com';
$to = 'to#gmail.com';
$subject = 'Customer Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$headers = 'From: From: from#gmail.com' . "\r\n" .
'Reply-To: From: from#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}

Related

"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.

php contact form to display the email address of the sender in inbox

I would like to create a form that will simply allow the recipient of the messages the ability to click 'reply to' when responding to a website message from their inbox. The reply should auto populate with the sender's email address.
I think that I need to change the $mailheader from a specific email address to .$_POST, but my attempts are not working correctly. I feel like it must be something small that I am doing incorrectly.
Here is the php form code. It is working as is, but I am attempting to edit/improve usability:
<?
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$security = $_POST['security'];
$to = "website-owner#gmail.com";
$subject = "Contact Message from Website";
$message = "A visitor of exampledomain.com has submitted the following message.\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage: $message";
$mailheaders = "From: webmaster#example.com\r\nReply-To: webmaster#example.com";
if ($security=="10") {
mail($to,$subject,$message,$mailheaders);
header("Location:contact.php?s=1");
}
else {
header("Location:contact.php?s=2");
}
?>
This was my first attempt:
$mailheader = "From: ".$_POST["email"]."\r\nReply-To: ".$_POST["email"]."\r\n";
This was my second attempt:
$mailheaders .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheaders .= "From: ".$_POST['Email']."\r\n";
This was my third attempt:
$mailheaders = "Reply-To: ".$_POST["email"]."\r\n";
$mailheaders = "From: ".$_POST['Email']."\r\n";
I figured it out! This mail header works.
$mailheaders = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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.

PHP Unknown sender

Hello I am fairly new to PHP and do not know a lot at the moment. I have modified a contact form an have come into some problems regarding the mail going straight to junk.
I assume this is for the reason that (unknown sender) keeps displaying in the email header. I would appreciate it if someone could help me correct this. The following is the code that I have implemented into the website:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Wirral PT Enquiry';
$to = 'joebloggs#hotmail.com';
$subject = 'Wirral PT Enquiry';
$human = $_POST['human'];
$headers = "enquiry#wirralpt.co.uk";
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '2') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p> 1+1=2!! </p>';
}
} else {
echo '<p>You need to fill everything!!</p>';
}
}
?>
$from = 'From: Wirral PT Enquiry'; should contain the 'from' email address, not just the name:
$from = 'From: Wirral PT Enquiry <enquiry#wirralpt.co.uk>';
Try that?
try using
$headers = "Reply To :enquiry#wirralpt.co.uk";
Might work for you
also,
$headers = "From :enquiry#wirralpt.co.uk";
try both of these with you relevant email IDs
Change your headers to this:
$headers = 'From: enquiry#wirralpt.co.uk' . "\r\n" .
'Reply-To: enquiry#wirralpt.co.uk' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
and your mail should look this this:
mail ($to, $subject, $body, $headers)
This error can also be caused if while using SMTP settings for PhpMailer, $mail->IsSMTP(); is missed

HTML Form data via 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.

Categories