Sent mail from my site to members appears as spam - php

I have a site and I want to email the active code to my new members. I have an unique IP too, but when I send an email with "Mail" function in PHP, the email would appear on their Spam. How can I send the email to my members that appear on their Inbox??
$headers = "From: info#mysite.com\r\n";
$headers .= "Reply-To: info#mysite.com\r\n";
if ( mail("myemail#gmail.com","Test","Hello,world !",$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}

Most email hosts, have a system which favor "Normal text", in received e-mails. Any type of emails with unusual letters have a greater tendency of ending up in the spam-filter. Try to take a look at what the e-mail your sending them actually looks like, and see if there's anything that might appear "unusual".

Try this...
$to = "emailaddress#tosendto.com";
$subject = "Put Subject Here";
$message = "Put at least a paragraph of text";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html\r\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
$headers .= "From: info#mysite.com\r\n";
$headers .= "Reply-To: info#mysite.com\r\n";
if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
Make sure that the email address that the emails are being sent from, exists.

Related

How to avoid PHP mail output going to junk mail? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
My mails using php mail() are going to the junk mail folder - why?
<?php
ob_start();
session_start();
//define the receiver of the email
$from='mrashidap#gmail.com';
$to = 'mrashidap#gmail.com';
//define the subject of the email
$subject = 'inform me please, when u receive this mail';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
#Now We Can Use HTML Tags
$headers = "From: " . strip_tags($from). "\r\n";
$headers .= "Organization: appstribes\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Reply-To: ".($from) . "\r\n";
$headers .= "Return-Path: ".($from) . "\r\n";
$headers .= "X-Priority:3 \r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$headers .= "X-MSMail-Priority: high\r\n";
$msg = '<html><body>';
$msg .= '<p>Dear Sir/Madam</p><br/>';
$msg .= '<p><strong>GOOD DAY..!!!</strong></p>';
$msg .= '<p>Thank you for contacting Keita Customer Service. We regret any inconvenience you have experienced. Your request has been received, and a ticket has been created for you with,</p>';
$msg .= '<p><strong>Reference ID : khd004</strong></p>';
$msg .= '<p>Our team is looking into your request and you can expect next to be contacted with either an answer to your question(s) or a solution to the issue(s) raised. Our expected time-frames to respond will vary according to the severity or complexity of the matter being addressed and volume of contacts reaching us. However we assure you that we are working to get back to you as fast as possible and to properly address your questions and concern.</p>';
$msg .= '<p>Regards,</p>';
$msg .= '<p>Keita IT Team</p><br/>';
$msg .= '</body></html>';
$message=$msg;
//send the email
$mail_sent = #mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
Most of the mails are going to junk. However mail sending to gmail are getting in inbox itself.
Your script claims this email is sent from gmail, which is not true
Not clear whether your server signs emails with DKIM or not, does it have SPF or not
Server may be graylisted
Google may not designate your domain as a permitted sender
Any of these reasons may lead to considering your emails as spam.

PHP send Multiple email not working

In my following code it working fine for one email id but when I changed $to with two email id like $to = "test1#gmail.com,test2#gmail.com" then it not sent email to receptions emails.
$to = "test1#gmail.com";
$subject = "Student details";
$msg = "Body Message here";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
if(mail($to,$subject,$msg,$headers))
{
echo "email sent successfully";
}
Might be this question look like silly but it difficult for me to debug why it is not working for multiple email.

Php mail. Can't get email on one address

I have a problem with my mail in php. I code form to send email. I receive email on gmail but I have other mail address and I can't get email on it.
I checked in spam and there is no email also.
Below is my code.
<?php
$emailErr = "";
$endMessage = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["email"])) {
$emailErr = "Proszę uzupełnić pole e-mail";
}
else if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$namesurname = $_REQUEST['name_surname'] ;
$email = $_REQUEST['email'] ;
$number = $_REQUEST['number'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$message = $subject . ": " . $message . " " . $number . " " . $namesurname . " " . $email;
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
mail("szafor#szafor.pl", "Zamówienie pomiaru",
$message, "From: formularz#szafortest.pl \r\n"."Content-Type: text/plain; charset=UTF-8\r\n");
$endMessage = "Dziękuję za przesłanie wiadomości.";
}
}
?>
One important thing to consider with sending mail is that you should at least have the return path of the message be an email address that is actually hosted on the server that you are sending from.
You can set the From and the Reply-To address as any address, but the return-path should be set to a valid email address hosted on your server. Let's say that you want the "reply" button to send back to "this_email#wherever.com" but the server you are using hosts email for "mydomain.com". Create an email account on your server, "info#mydomain.com" for example.
$recipient = "sendto#email.com";
$subject = "Test email";
$message = "This is the message.";
$headers .= "From: Your Name Here <any_email#wherever.com>\n\r";
$headers .= "Reply-To: Your Name Here <any_email#wherever.com>\n\r";
$headers .= "Return-Path: Your Name Here <info#mydomain.com>\n\r";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
$headers .="X-Mailer: PHP/" . phpversion() . "\r\n";
$headers .="MIME-Version: 1.0\r\n";
mail($recipient, $subject, $message, $headers);
I have found that the more valid header information that I provide, the more likely the email will be delivered. Right now these headers always work for me, and I have a scheduling program that is sending email to a hundred different email addresses every day. See if that works better for you.

PHP Send a mail to user mail address entered into a text box

I am trying to make a simple form that sends the user defined/entered email address a link to them.
Visitor > Enter Mail > Hit Send > Receives a mail with a link
But I am battling to make it work.
$headers = "From: Siddharth Jain <email>\r\n";
$headers .= "Reply-To: Siddharth Jain <email>\r\n";
$headers .= "Return-Path: email\r\n";
$headers .= "Bcc: Siddharth Jain <email>\r\n";
$headers .= "PHP/" . phpversion();
$to = $_REQUEST['email'];
$subject="";
$mailcontent='Codeword: '.$_POST["text_box"];
mail($to, $subject, $mailcontent, $headers);
Replace "email" with your email and "Siddharth Jain" with the name you need to display in that email.
thanks Mitali Mehta :)
Got this to work.
<?php
// Contact subject
$subject ="mail subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="no-reply#domain.com";
// From
$header="from: no-reply#domain.com";
// Enter your email address
$to = $_REQUEST['customer_mail'];
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
header("Location:http://www.domain.com/");
}
else {
echo "ERROR";
}
?>
in case someone else wants it :)
also this sends me a copy of the request too.

mail not getting sent on server

I have 2 websites on hosted but on one web site I can send mail using php script using other web site I cannot mail using the php script. I don't know where I am going wrong. I even replaced php.ini file. Is there any other thing which I left doing or something.
This is my code
$to="abc#gmail.com";
$subject="test mail";
$body="test mail";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers.='From: Domain <def#gmail.com>' . "\r\n";
if(mail($to,$subject,$body,$header))
{
echo "mailed";
}
else
{
echo "not mailed";
}
I even tried directly embedding message into the mail function that also doesn't seems to be working.
This is the code after embedding message
if(mail("abc#gmail.com", "Test subject", "Test Message", "From: def#gmail.com"))
{
echo "mailed";
}
else
{
echo "error:".mysql_error();
}
I tried contacting my hosting providers technical people. Even they could not find the solution.
it's Sample And Works for me:
$to ='Info#sample.com';
$message = '<a>Hellow</a>';
$subject ='Hello world';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: <sender#email.com>" . "\r\n";
$mail_sent=#mail($to,$subject,$message,$headers);
echo $mail_sent ? "Success" : "Error";
if this code not working , Call to Your server Administrator For check Server...

Categories