2

I am using Symfony 1.4.8 and Propel as ORL. I am sending mails using Symfony miler object, the mail is send properly but it goes to spam folder, is there any way to stop that. the code that i am using,

$to_email_array=array("one@gmail.com","two@gmail.com");
$body="welcome to symfony";
$subject="from Symfony";
$from=array('me@mydomain.com' => 'our Domain');
$mail_object=$this->getMailer();
$message=Swift_Message::newInstance()
                                 ->setSubject($subject)
                                 ->setBody("<html> <head> </head> <body> <span>Dear {receiver}, </span>".$body."</body> </html>", "text/html")
                                 ->setFrom($from)
                                 ->setTo($to_email_array);
$mailed=$mail_object->batchSend($message);

The above code is called from a Symfony Task, and we are using our own web server to send mail, with our domain name. The mail is send, but it goes to spam folder. Is there any way to stop the mail going to spam folder.

Harish Kurup
  • 7,257
  • 19
  • 65
  • 94
  • This may be relevant to your interests: http://stackoverflow.com/questions/4851449/building-a-enewsletter-sending-system-avoiding-spam . In short: No, there is no *reliable* way to achieve that; the question lists some resources to help the odds. – Piskvor left the building Feb 17 '11 at 13:55
  • Are there any headers added to the received email by the spam detector (X-Spam-whatever, or anything like it)? They can help in figuring out what's going on; some of them even indicate a list of the rules that have been triggered during detection. Only one thing I'd do differently from your above code that I can see is use a text/plain part _as well_ as a text/html part; HTML-only emails can be seen as "spammier" than those with a text part. – Matt Gibson Mar 10 '11 at 10:50
  • If you can provide "Full email header" It will be easier to determine. Send it to -someone-@gmail.com and Click on "Show Original" from the drop down menu (towards the top right corner of the message box). paste it over here, so that I/we can analize further. – Rahul Prasad Mar 14 '11 at 09:15
  • @Matt Gibson i am using the symfony's build in mailer(i.e the swift mailer) and not setting any header as such, need to check that. – Harish Kurup Mar 14 '11 at 11:21
  • @Rahul Prasad i will try to get that. – Harish Kurup Mar 14 '11 at 11:24
  • @Harish I'm not thinking about headers added when sending -- when a spam filter analyses an email, it will often add its own headers to the email to indicate what it detected. I'm suggesting you check the headers of the emails you're finding in the spam folder, to see whether the spam filter added helpful headers to them to indicate why it marked the mail as spam. – Matt Gibson Mar 14 '11 at 11:42
  • @Matt Gibson, is this the error you are saying "Received-SPF: error (google.com: error in processing during lookup of jobs@mstrecruiter.com: DNS timeout) client-ip=174.122.37.39; Authentication-Results: mx.google.com; spf=temperror (google.com: error in processing during lookup of jobs@mstrecruiter.com: DNS timeout) ) " – Harish Kurup Mar 14 '11 at 12:07
  • @Harish By the looks of it, Google is attempting to see if you have [SPF](http://en.wikipedia.org/wiki/Sender_Policy_Framework)-related DNS records. (You don't, but that's not necessarily a problem.) From the error you're seeing, though, it looks like Google's lookup of DNS records for mstrecruiter.com is timing out. I'd guess that if Google can't check that your IP address matches your claimed hostname, then it'd increase your spam score. Have you had any DNS problems recently? Could your ns1/ns2 DNS servers at 174.122.37.39 and 174.122.37.40 have been unresponsive while Google were checking? – Matt Gibson Mar 14 '11 at 13:41
  • @Matt Gibson yeah we had a DSN problem, the site was not opening at some network, with mstrecruiter.com but it does with the IP. – Harish Kurup Mar 15 '11 at 05:24
  • 1
    @Harish Well, that'll definitely raise your spam score, because spam-checking systems will do a DNS lookup on you to check the sender IP address against the domain it's purporting to be from. Fix your DNS issues and far less of your mail will be marked as spam. – Matt Gibson Mar 15 '11 at 07:55

3 Answers3

5

Spam filtering can be either based on infrastructure problems, or on message content. You will need to tell us more about your setup, or try a few things, to work out where the problem is:

  1. Do you have a unique IP for your web server, and you have reverse DNS set up for your web server IP?

  2. Do you have a SPF record in DNS designating your web server as authorized to send email for your domain? If you're not sure what I mean, you can read this: http://www.open-spf.org/Tools/

  3. Which email service(s) or client(s) are junking/bouncing the emails? Are there any added message headers indicating what filter rules were matched?

Alcalyn
  • 1,531
  • 14
  • 25
Terence Johnson
  • 1,637
  • 1
  • 16
  • 21
  • we are using our own Webserver to send Email, and no other client or email service. example i have a domain name mydomain.com and my email id is me@mydomain.com. we are using PHP script to send email. – Harish Kurup Feb 17 '11 at 14:10
  • @Harish: is part #1 ok: the unique IP and reverse DNS of it? Check the mailheaders of the mails that arrive as spam, and see if you can detect any obvious spamrules being triggered. – Mojah Mar 14 '11 at 22:50
  • Also note that many spam filtering tools actually mention **why** the mail was marked as spam. This information is usually found in the email's header field... – Martin Tournoij Mar 16 '11 at 00:25
  • Having an SPF record does not prevent anybody from having your messages classified as spam. SPF records is just a means to restrict the ranges of IP addresses from which messages sent from one domain can be set. Messages from one domain sent from IPs not matching the SPF recorded can be considered to be spam. – mlemos Mar 16 '11 at 01:21
  • 1
    @mlemos: SPF and reverse DNS are low-hanging fruit. Without them you are going to be marked as spam, with them you may still be marked as spam. Once you have all your technical ducks in a row, you have to accept that some receiving mail systems are just going to mark your transactional emails as spam because they feel like it, or spam you with challenge-response messages. Some of the bigger services like AOL and Yahoo have whitelists you can get on if you play nicely. However, false positives don't really hurt the free-email-service business model very much. – Terence Johnson Mar 23 '11 at 14:31
0

You need to setup DKIM and SPF which can be done easily by watching this video. Those will allow other sites to verify emails actually came from you and can be trusted.

Xeoncross
  • 55,620
  • 80
  • 262
  • 364
0

What I generally find to work for me is to specify all addresseses (To, From, Cc, etc) in RFC822 format, like so:

To: "John Doe" <ddd@Org.tld>

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49