Mail always goes to spam folder

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Mail always goes to spam folder

Post by goldfiles »

I think I have swift mailer setup correctly, and my domain isn't blacklisted, but all of my emails are being sent to the spam folder. Is there a way I can check to find out why they are being junked? I read something about using spam assassin, but I didn't quite follow how to see spam assassin analysis of the email.

I am on a shared, linux, cpanel hosting account if that matters. I do have spam assassin enabled, but how do I see what it says about my emails? (my emails are getting junked in gmail and yahoo, but not actually on my server)

Here is my code if that helps:

Code: Select all

 
require_once "swift/lib/Swift.php";
require_once "swift/lib/Swift/Connection/SMTP.php";
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost", 25));
 
$message =& new Swift_Message("My Subject");
$message->attach(new Swift_Message_Part("My plain message."));
$message->attach(new Swift_Message_Part("My <strong>html</strong> message.", "text/html"));
 
if ($swift->send($message, "to@toaddress.com", "from@mysite.com")) {
    echo "Message sent";
}
else {
    echo "Message failed to send";
}
 
$swift->disconnect();
 
I've been at this for hours now....help!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

Have you read over the notes here? http://swiftmailer.org/wikidocs/v3/tips/spam

Key things:

Make sure you have an SPF record
Make sure you're not blacklisted (enter SMTP IP address here: http://www.robtex.com/rbl/ )
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

Thanks for the quick reply!

Yes, i have visited robtext.com (great site btw). My host is not blacklisted.

How do I make sure I have an SPF record?

(update: i was able to send mail to another one of my cpanel accounts on a different server, and it had a spam assassin score of 0.)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

An SPF record is a DNS record with the type of TXT. You'd find it in your DNS control panel somewhere.

A quick Google showed this:

http://www.kitterman.com/spf/validate.html
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

It says something about PermError. What's wrong with it?
Input accepted, querying now...

SPF records are primarily published in DNS as TXT records. The TXT records found for your domain are:

v=spf1 ip4:75.127.94.117 a mx a:janus.nswebhost.com mx:textadmarket.com include:janus.nswebhost.com -all


SPF records should also be published in DNS as type SPF records. This is new and most implementations do not support it yet.
No type SPF records found.

Checking to see if there is a valid SPF record.

Found v=spf1 record for textadmarket.com
v=spf1 ip4:75.127.94.117 a mx a:janus.nswebhost.com mx:textadmarket.com include:janus.nswebhost.com -all

evaluating...
Results - PermError SPF Permanent Error: No valid SPF record for included domain: janus.nswebhost.com: include:janus.nswebhost.com
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

Your SPF record tries to include the record from a domain which doesn't have an SPF record.

Code: Select all

include:janus.nswebhost.com
That's saying "Include all the SPF record data from janus.nswebhost.com"... BUT janus.nswebshost.com does not have a SPF record.

I'd probably speak to your host.

PS: I assume you are testing Swift on your web host and not on your own computer?
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

Ahhh, thanks! The SPF record stuff is a bit confusing to a noob like myself.

Yes, I am doing my swift testing on the actual site. I'll speak with my host to see what they know. Thanks again.
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

My host has setup SPF for the janus.web.nswebhost.com sever that my site is located on, but now this error comes up when checking for the SPF record of textadmarket.com

evaluating...
Results - PermError SPF Permanent Error: include has trivial recursion: include:janus.nswebhost.com

(and my emails are still getting junked..)

thoughts?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

Ok, so is this an SPF record for janusweb.nswebhost.com? And it's trying to "include:" the record for itself? That will cause recursion since the "include:" points to itself, so it tries to include it, sees the "include:", then tries to include itself, sees the "include:" then tries to include itself. You get the idea.

Remove the "include:" entirely if this is the case. I might suggest using the SPF record generation tool on the openspf website:

http://old.openspf.org/wizard.html
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

Yes, I just did a lookup on janus.nswebhost.com and it tries to include itself recursively:

Code: Select all

w3style-2:~ chris$ dig TXT janus.nswebhost.com
 
; <<>> DiG 9.4.1-P1 <<>> TXT janus.nswebhost.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23285
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
 
;; QUESTION SECTION:
;janus.nswebhost.com.       IN  TXT
 
;; ANSWER SECTION:
janus.nswebhost.com.    14400   IN  TXT "v=spf1 ip4:75.127.94.117 a mx a:janus.nswebhost.com include:janus.nswebhost.com -all"
 
;; AUTHORITY SECTION:
nswebhost.com.      10844   IN  NS  ns2.nswebhost.com.
nswebhost.com.      10844   IN  NS  ns1.nswebhost.com.
 
;; ADDITIONAL SECTION:
ns1.nswebhost.com.  10790   IN  A   64.22.70.65
ns2.nswebhost.com.  10790   IN  A   70.47.27.128
 
;; Query time: 261 msec
;; SERVER: 192.168.2.100#53(192.168.2.100)
;; WHEN: Mon Apr 21 17:23:01 2008
;; MSG SIZE  rcvd: 202
 
w3style-2:~ chris$
The line which contains TXT shows the SPF record for that domain. You can see the include in there. Remove it ;)
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

Sorry, I'm not very good at this stuff. My host is the one that set this SPF record up. What exactly should I tell them to remove, this part?
# ;; ANSWER SECTION:
# janus.nswebhost.com. 14400 IN TXT "v=spf1 ip4:75.127.94.117 a mx a:janus.nswebhost.com include:janus.nswebhost.com -all"
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

goldfiles wrote:Sorry, I'm not very good at this stuff. My host is the one that set this SPF record up. What exactly should I tell them to remove, this part?
# ;; ANSWER SECTION:
# janus.nswebhost.com. 14400 IN TXT "v=spf1 ip4:75.127.94.117 a mx a:janus.nswebhost.com include:janus.nswebhost.com -all"
No, just the include:

Code: Select all

include:janus.nswebhost.com
That's the problem. Pretty bad of a host to get it so wrong ;)
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

Okay, my host seems to have updated the SPF, and it is correct now! Good advice!

But, my emails are still going to spam folders!! lol, back to square one! I've been with this host for 3 years, but I'm seriously considering switching. My emails scripts DO work on other servers I have, so I'm convinced that this host hasn't setup their server correctly.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail always goes to spam folder

Post by Chris Corbyn »

goldfiles wrote:My emails scripts DO work on other servers I have, so I'm convinced that this host hasn't setup their server correctly.
Sounds that way. Another issue is if their server is not correctly indentifying itself when connecting to remote hosts to relay mail. I can't check that I'm afraid, they have to do that.
User avatar
goldfiles
Forum Commoner
Posts: 27
Joined: Sun Nov 12, 2006 5:50 pm

Re: Mail always goes to spam folder

Post by goldfiles »

Spoke with my host. They didn't care enough to send a test email from their server, and they said they didn't want to look into the broken email (its broken for everyone on the server i found out). They told me I could either deal with the broken email or find a new host! lol...i was shocked because I thought hostingzoom and resellerzoom were quality companies. Then again, I was speaking with their outsourced Indian tech support. I got what I paid for I suppose.
Post Reply