Mail is not Going in PHP - php

i am not able to send email in php,Any one help me to identify
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
i am not able to send email in php,Any one help me to identify where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem. where i am wrong.After filling form All details has to go a specified email.but here it is displaying else condition.So,Please help me to solve this problem.
<?php
$englishname = $_REQUEST['firstname'].'&nbsp'.$_REQUEST['lastname'];
$arabicname = $_REQUEST['firstnamearabic'].'&nbsp'.$_REQUEST['lastnamearabic'];
$education = $_POST['education'];
$ar_education = $_POST['educationarabic'];
$email = $_POST['email'];
$country= $_POST['parent_cat'];
$city= $_POST['cit_cat'];
$area= $_POST['area'];
$mobilenumber= $_POST['mobileno'];
$doorno= $_POST['doorno'];
$phone= $_POST['phoneno'];
$street= $_POST['street'];
$apartment = $_POST['apartment'];
$experience = $_POST['experience'];
$postalcode = $_POST['postelcode'];
$landmark = $_POST['landmark'];
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'addEmployee')
{
$to = 'arundsti#gmail.com';
$subject = 'NEW DOCTOR REGISTRATION DETAILS-FIND A DOCTOR';
$from = $_REQUEST['email'];
// mandatory headers for email message, change if you need something different in your setting.
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "CC: info#findadoctorsa.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "Name in English: $englishname.\r\n";
$message .= "Name in Arabic: $arabicname.\r\n";
$message .= "Education: $education \r\n";
$message .= "Education in Arabic: $ar_education \r\n";
$message .= "Email: $email \r\n";
$message .= "Country: $country \r\n";
$message .= "City: $city \r\n";
$message .= "Area: $area \r\n";
$message .= "Mobilenumber: $mobilenumber \r\n";
$message .= "DoorNumber: $doorno \r\n";
$message .= "PhoneNumber: $phone \r\n";
$message .= "Street: $street \r\n";
$message .= "Apartment: $apartment \r\n";
$message .= "Experience: $experience \r\n";
$message .= "Postalcode: $postalcode \r\n";
$message .= "Landmark: $landmark \r\n";
$sent = mail($to, $subject, $message, $headers);
if($sent){ ?>
<script>
alert('Your Details received Successfully...We will Touch with you shortly');
</script>
<?php
}
else {?>
<script>
alert('Sorry Problem in Submitting Details,Please try Again');
</script>
<?php
}
}
?>

Related

How to Attach some Files In Mail in Simple PHP

I have made mail function in PHP, I use mail_to function and simple mail has been sent but the attachment file didn't. in this code I want the user send any type of file in the mail If I use any code of attachment get the error in page and page not open anyone helps me?
if(isset($_POST['submit']))
{
$pack = $_POST['pack'];
$position = $_POST['position'];
$name = $_POST['name'];
$email = $_POST['email'];
$re_no = $_POST['re_no'];
$phone = $_POST['phone'];
$rfc_no = $_POST['rfc_no'];
$comment1 = $_POST['comment1'];
$comment2 = $_POST['comment2'];
$comment3 = $_POST['comment3'];
$tandc = $_POST['tandc'];
$tandc2 = $_POST['tandc2'];
$file1 = $_POST['file1'];
$file2 = $_POST['file2'];
$file3 = $_POST['file3'];
$to = 'bhupendra.w3ondemand#gmail.com';
$subject = 'MUV Express Delivery Enqury';
$headers = "From: $email";
$message = "Package: $tp\r\n";
$message = "Package2: $pack\r\n";
$message = "Name: $name\r\n";
$message .= "Email: $email \r\n";
$message .= "Phone: $phone \r\n";
$message .= "Re No: $re_no \r\n";
$message .= "Position: $position \r\n";
$message .= "R.F.C. No.: $rfc_no \r\n";
$message .= "Comment1: $comment1 \r\n";
$message .= "comment2: $comment2 \r\n";
$message .= "comment3: $comment3 \r\n";
$message .= "Check: $tandc \r\n";
$message .= "Check2: $tandc2 \r\n";
$message .= "File1: $file1 \r\n";
$message .= "File2: $file2 \r\n";
$message .= "File3: $file3 \r\n";
$message .= "Brief Description: $briefdesc \r\n";
$sent = mail($to, $subject, $message, $headers);
$_SESSION["po"] = $_POST['position'];
if($sent) {
echo "Success";
header("Location: http://dev.w3ondemand.com/development/muvexpress/profile.php");
}
else {
echo "Failure";
header("Location: http://dev.w3ondemand.com/development/muvexpress/negocios.php");
}
}
Please map your variables accordingly.
<?php
$subject = 'Your message subject';
$encoded_content = chunk_split(base64_encode($your_file_content_here));
//header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:".$your_from_email."\r\n";
$headers .= "Reply-To: ".$reply_to_email."\r\n";
$headers .= "Content-Type: multipart/mixed;\r\n";
//plain text
$message .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n\r\n";
//attachment
$message .="Content-Type: $file_type; name=".$file_name."\r\n";
$message .="Content-Disposition: attachment; filename=".$file_name."\r\n";
$message .="Content-Transfer-Encoding: base64\r\n";
$message .="X-Attachment-Id: ".rand(1000, 99999)."\r\n\r\n";
$message .= $encoded_content;
$sentMailResult = mail($to, $subject, $message, $headers);
?>

Php contact form keeps going to spam and has an html attachement

I experiencing a problem with a php contact form that I normal use on our products sites.
<?php
$to = "martin#puritech.co.za";
$subject = "Reverse Osmosis";
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['tel'];
$mail = $_POST['message'];
$headers = "From: $name \r\n";
$headers .= "Email: $email \r\n";
$headers .= "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html charset=iso-8859-1 \r\n";
$message = "<html><body style='font-family: Arial;'>";
$message .= "<h1>Hello Guys! You have a request from ".$name."</h1>";
$message .= "<p>".$mail."</p>";
$message .= "<p><span style='font-weight:bold;'>From:</span> ".$name."</p>";
$message .= "<span style='font-weight:bold;'>Email:</span> ".$email."</p>";
$message .= "<span style='font-weight:bold;'>Contact Number:</span> ".$number."</p>";
$message .= "</body></html>";
$send = mail ($to, $subject, $message, $headers);
if ($send==true) {
header('Location: ../index.html');
exit;
}else {?>
<script type="text/javascript">
alert('Please check your details and resend. Thank you.');
window.location = '../index.html';
</script>
<?php
}
?>
When I click on the send button, the mail goes straight to spam and has an html doc attachment.
How do I fix this? really draining me and its starting to annoy me.

How to add a cc in a php contact form?

I have a contact form for a HTML page. Right now the recipient is only one. How can I add multiple recipient. Any help on this would be a great help.
Code is below.
Thanks.
<?php
$to = "support#domain.in";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = "Message from $name ($email)";
$replyto = $email;
$headers="";
$headers = "From: test <domain#one.com>\n";
$headers .= "Reply-To: $replyto";
$result = mail($to,$subject,$message,$headers);
?>
Here is your sample code
$to = "xyz#somedomain.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:abc#somedomain.com \r\n";
$header .= "Cc:afgh#somedomain.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}

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

Include Variables in PHP mail command

I'm sure I'm wrong about something basic, but can not find where the error is. I will appreciate your help.
I have a php page with a single 4 fields contact form.
I need send the name and email as variable, so i can see it properly when email is received.
IT WORKS - BUT DONT SEND NAME AND EMAIL AS VARIABLE:
All messages arrives as "no-reply#luchodomain.com" and doesnt look professional (and can't do reply from my outlook)
if ($_POST) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: no-reply#luchodomain.com" . "\r\n" ;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body>";
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
mail($to,$subject,$message,$headers);
}
IT DOENST WORKS (but have the format and variables as i need)
I would like receive the messages like is normal Name, so i can do a quick reply. -This code don't send email, doesn't work-
if ($_POST) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body>";
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
mail($to,$subject,$message,$headers);
}
I will appreciate your help with this "headers" issue!
Thank you.
Make sure that you are receiving data in your post array. Make sure your form action. You have declared $message variable to blank after assigning the post value in it before. That's not a good trick enough. Please check updated code and let me know.
if ($_POST) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$subject = strip_tags($_POST['subject']);
$message = strip_tags($_POST['message']);
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//$message = "";
//$message .= '';
$message .= "\r\nName: " . $name . "";
$message .= "Email: " . $email . "\r\n";
$message .= "Subject: " . $subject . "\r\n";
$message .= "Message: " . $message . "";
//$message .= "";
//$message .= "";
mail($to,$subject,$message,$headers);
}
$to = 'pawanvikasitha2001#gmail.com, aravindasamapath87#gmail.com'; $subject = 'NEW ORDER HAS PLACED'; $message = "$name"; mail ($to,$subject,$message);
When you use the double quotes, You can simply add variables to it. Look at the $message

Categories