This question already has answers here:
How do you make sure email you send programmatically is not automatically marked as spam?
(24 answers)
Closed 7 years ago.
My code looks like this
$to = "mymailid#gmail.com";
$subject = "sample subject";
$body = "<div> hi hi .. </div>";
$headers = "Reply-To: The Sender <mymailid#gmail.com>\r\n";
$headers .= "Return-Path: The Sender <mymailid#gmail.com>\r\n";
$headers .= "From: The Sender <mymailid#gmail.com>\r\n";
$headers .='X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($to, $subject, $body,$headers)
I have sent the suitalbe header in my mail function. Everytime when i run this code, my mail will go to the spam folder in my gmail account.. How do i avoid my mail going to spam folder?
It can fixed by passing complete header information informing the mail provider as the sender is a trusted domain (https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail) also some DNS settings involved.
You can find the detail information here:
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
https://www.digitalocean.com/community/questions/email-goes-to-spam-gmail-php
Related
I write a script to send email from my website. I recieve email in inbox in gmail, outlook and hotmail but in yahoo, its going to SPAM folder and also URL in not working in yahoo. Whats wrong in my code,
Header
$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";
Message with URL
$message.= "<a href='https://www.google.com'>Click here</a>";
PHP-Mail function is not uses a well configured SMTP Server so may be this is a reason or try to Use the PHPMailer-Class. or you need to try with full headers
Also links not working cause your mail in spam. need to move in inbox and see.
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
For more info follow:- sending email via php mail function goes to spam
This question already has answers here:
Prevent sent emails treated as junk mails using php mail function
(14 answers)
Closed 9 years ago.
I used this tutorial for sending mail :
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
My code looks like this :
$headers .= "Reply-To: The Sender <sender#sender.com>\r\n";
$headers .= "Return-Path: The Sender <sender#sender.com>\r\n";
$headers .= "From: The Sender <senter#sender.com>\r\n";
$headers .= "Organization: Sender Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n"
mail("recipient#recipient.com", "Message", "A simple message.", $headers);
I am using localhost(MAMP PRO) for sending mail.
But mail goes to spam folder.How to send mail which goes to inbox.Please guys help me out from this,i spend a lot of time on it.
Which folder an email goes into depends mostly on the domain & ipaddress from which the email is coming from and the email service provider. If your domain/ip is trusted by the service provider it will not be spammed.
Also, after setting a few emails as "Not Spam" from that domain, your email service will no longer spam the emails
there are more than one reason ur email goes to spam ...
1 - make sure that the "from email" is actually the email u are sending the emails from .. i mean dont use any other false "from Email"
2- you have to keep the message body simple as possible . dont use so much html tags and css experssions , and also try to use tables
This question already has answers here:
php email - how to avoid mail ending up in spam box
(6 answers)
Closed 9 years ago.
My emails are being flagged as spam. How can I prevent this? Here's how I'm sending them:
public function sendMail($to,$subject,$from,$headers)
{
$headers .= "From: ".$from. "<support#mydomain.com>";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: smail-PHP ".phpversion()."\r\n";
$message .= $this->getMessage();
return mail($to,$subject,$message,$headers);
}
You can partially control it, add headers in correct format..use swiftmail or other apart from php mail() some mail servers feel bad if send via php mail()
Check for any blacklisting as well from mail servers.
Always test it on live wires, check FILTERS if you are using Yahoo.
This question already has answers here:
How do I prevent mails sent through PHP mail() from going to spam? [duplicate]
(6 answers)
Closed 9 years ago.
Below is header to sent to user:
$to="$mail";
$sub="Thank you!";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
$headers .= 'From: example.com <noreply#example.com>' . "\r\n";
$msg="Dear $nme ,<br/> We received a request to recover your password.<br/> Your Password is $pss .";
$response =#mail($to,$sub,$msg,$headers);
If i send it through diff sever it goes to inbox.
How can I prevent email going to spam?
$to='example#gmail.com';
$subject='Application Form ';
$message='testing';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: admin <admin#gmail.com>' . "\r\n";
if(mail($to,$subject,$message,$headers))
{
echo "Mail Successfully Sent..";
exit;
}
It works perfectly to me. You can also use SMTP MAIL instead of this.
I think generally, a mail is termed as spam or not spam on the receiving end of it, not the sending end - or else any spammers would simply say that all of their messages are not spam, completely defeating the purpose. Thus, you can't just force a message to go to a sender's inbox.
However, what you may need to do is see if the machine that you're using to send mail is currently listed on any spam blocklists, and if so, take the necessary steps to remove it from those blocklists.
I am trying to send new system generated password using mail() in php. The thing is I am able to send it to yahoo but when I use gmail or hotmail I dont receive any emails although the function returns true. Following is the function:
if(mail($to,$subject,$body))
{
return true;
}
else
{
return false;
}
It probably ends up in the spam folder look there. If its there make sure your email headers are perfect.
You could look into librairies for what you want to achieve. Zend_Mail has everything you could need to connect to gmail and others.
If you are getting the mail successfully through yahoo, you should also post the headers that are coming through from yahoo here in the question. My bet is you will need to include a "from field" also to get through on hotmail, gmail, etc...
Your problem might be the antispam filters. E-mails sent from PHP are usually marked as spam by the mail servers and end up deleted or in the spam can.
You can Google for "php mail spam" to get some hints of how to work around this issue.
Maybe you're on a shared server and the IP is banned/blocked due to spamming by other users (websites) of your server.
Try adding SPF records.
Ensure that your envelope-FROM (a.k.a. return path) is set to a valid email address that you have access to. If you're not seeing the message in the spam folders, it should be getting bounced; the bounce message may offer a clue as to why the mail is not getting through.
I would try to include your own headers in your mail function
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Date: ". date('r'). " \r\n";
$headers .= "Return-Path:youremail#domain.com\r\n";
$headers .= "Errors-To:youremail#domain.com\r\n";
$headers .= "From:youremail#domain.com <youremail#domain.com>\r\n";
$headers .= "Reply-to:youremail#domain.com \r\n";
$headers .= "Organization: YourOrg \r\n";
$headers .= "X-Sender:youremail#domain.com \r\n";
$headers .= "X-Priority: 3 \r\n";
$headers .= "X-MSMail-Priority: Normal \r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
mail($to,$subject,$body,$headers);
Try checking if your mailserver ip is blacklisted anywhere?
http://www.mxtoolbox.com/blacklists.aspx
If not, try harder with the headers that are being sent with the mail.