How to prevent mail from going to spam? [duplicate] - php

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.

Related

PHP mail going to spam folder in Gmail [duplicate]

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

PHP Email Bcc from form

I've created a form to get information from end users and email to a specific person. I'd like for the form to also be emailed to the submitter. Everything works, except when I try to Bcc the submitter. If I add the line to Bcc, the email is not sent. If I delete the line to Bcc the email is sent correctly, but the submitter doesn't have a copy of the email. Here is the code,
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: $email' . "\r\n";
$headers .= 'Bcc: $email_bcc' . "\r\n";
Add the BCC Receiver to the recipients but NOT to the headers!
Using Bcc in the header should be fine. However, make sure, that your mail server is not killing the mail because of it.1
Check the return value of the mail function. This should return false, if an error occured. If that is the case, you should send an extra mail to the sender.
Windows Server seem to have a problem with this.

Sent mail from php goes into spam folder [duplicate]

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

How can I prevent my emails from being flagged as spam? [duplicate]

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.

php mail() doesnt work for gmail and hotmail

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.

Categories