Works on Gmail, but not Yahoo

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

rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Works on Gmail, but not Yahoo

Post by rotwyla98 »

Code: Select all

require_once "mail/Swift.php";

require_once "mail/Swift/Connection/SMTP.php";

$email = $_POST['user@yahooorgmail.com'];
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost", 25));
 
$message =& new Swift_Message("a html message", "text/html");
 
if ($swift->send($message, "$email", "admin@mysite.com"))
{
    echo "An email has been sent with your link!";
}
else
{
    echo "Message failed to send";
}
 
//It's polite to do this when you're finished
$swift->disconnect();
When the user@yahooorgmail.com is someone@gmail.com - the message gets sent
when it is someone@yahoo.com - no message is sent.

I downloaded the latest version today of php4 and my server runs on php5 (when I try to run the php5 version of swiftmailer, neither email gets sent)

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

Post by Chris Corbyn »

Does send() return true but the message never arrives, or is send() returning false? You may be being blocked as spam but I can't say without knowing the return value of the send() method ;)

If send() returns true, have a read over this: http://www.swiftmailer.org/wikidocs/v3/tips/spam
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

Well, I did appear on the Gmail SPAM folder (will follow those tips + how do I do multipart html + plain text emails?) but I still received the message.

http://www.robtex.com/rbls/207.234.130.11.html << Not blacklisted

Swiftmailer says its successful when I send it to both yahoo and gmail but yahoo doesn't receive it at all.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

rotwyla98 wrote:Well, I did appear on the Gmail SPAM folder (will follow those tips + how do I do multipart html + plain text emails?) but I still received the message.

http://www.robtex.com/rbls/207.234.130.11.html << Not blacklisted

Swiftmailer says its successful when I send it to both yahoo and gmail but yahoo doesn't receive it at all.
Multipart: http://www.swiftmailer.org/wikidocs/v3/ ... /multipart

Almost definitely sounds like a spam filter problem. How short is the message you're sending? HTML-only emails do suffer too (SA calculates the ratio of text to HTML and also the ratio of images to text, in addition to checking if the text actually says the same as the HTML. Short HTML messages, especially with images in will suffer.

When you checked the blacklist did you check the IP of your SMTP server or the IP of your web server?
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

its a dedicated server and the ip was for mail.mydomain.com

but yes.. it is in fact that Yahoo think the message is spam. When I add my email to address book, it works great.

Here is my message code:

Code: Select all

require_once "mail/Swift.php";
require_once "mail/Swift/Connection/SMTP.php";
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost", 25));

//Create a message
$message =& new Swift_Message("mysite.com - Free niche Guides");
 
//Add some "parts"
$message->attach(new Swift_Message_Part("Hey $name,/n Here is your link for the free guides!/n Please go to http://www.mysite.com/eval.php?e=$random_number to validate your email address and access your guides."));
$message->attach(new Swift_Message_Part("Hey $name,<br/>Here is your link for the free guides!<br/>Please click <a href=\"http://www.mysite.com/eval.php?e=$random_number\">HERE</a> to validate your email address and access your guides.<br/>", "text/html"));
 
if ($swift->send($message, "$email", "admin@mysite.com"))
What should I change/add?

Also, when I receive the email, the name shows up as "admin". Any way I can change that?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

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

Post by Chris Corbyn »

To be honest, as a human being reading what you just posted, it looks like spam. You use BLOCK CAPITALS which is a no-no (one of the many un-mentioned notes on that page I linked to), your message is one sentence long, linking to a remote website offering me something FREE...

I assume you're sending these to people who've asked for them but I suggest you think more tactfully about how you word the email. Try to bulk it out a bit for a start.

If I were a spam blocker I'd block that email personally ;)
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

followed some of those tips + some additions.

Decided to get rid of the html for extra anti-spam protection.

Code: Select all

require_once "mail/Swift.php";
require_once "mail/Swift/Connection/SMTP.php";
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost", 25));
 
$message =& new Swift_Message("MySite.com - Your Free Niche Guides", "Hey $name,/n
Here is your link for the free guides!\n\r Please go to http://www.mysite.com/eval.php?e=$random_number to validate your email address and access your guides.\n\r
\n\r
The above link is your personal link to verify your registration. You will then be automatically forwarded to the page with all of the guides you requested. All of these guides are written for free but cost lots of time and effort. Please be sure to vote for us (directions given on guides' page.\n\r
"));
 
if ($swift->send($message,new Swift_Address("$email", "$name"),new Swift_Address("admin@mysite.com", "Niche Guides"))){
    echo "Thank you $name, <br>An email has been sent to $email with your link!";
}
else
{
    echo "Message failed to send";
}
When I use the above code,nothing shows up on the next page + no error shows up. I inserted error_reporting (E_ALL); at the top but still no error, just a blank white page.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You're going to cause doubled-up line breaks using \n\r.... it's actually \r\n (the ordering does matter).

Also add display_errors...

Code: Select all

error_reporting(E_ALL); ini_set("display_errors", true);
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

I tried the code you gave me.. still didn't show any errors. Should I have safe_mode on or off?

Through a long process of commenting out code and replacing code, I found an extra parenthesis in my message :?

Send out the email....

the name shows up like I want it to on Gmail. Still SPAM on Yahoo.

I don't know what to do next =/

Email is not html.
I change the email address to a real one (mine) that is user@yahoo.com and its still SPAM.
Email isn't terribly short.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

rotwyla98 wrote:I tried the code you gave me.. still didn't show any errors. Should I have safe_mode on or off?

Through a long process of commenting out code and replacing code, I found an extra parenthesis in my message :?

Send out the email....

the name shows up like I want it to on Gmail. Still SPAM on Yahoo.

I don't know what to do next =/

Email is not html.
I change the email address to a real one (mine) that is user@yahoo.com and its still SPAM.
Email isn't terribly short.
It could be that you're trying to send from a Yahoo! email address when Yahoo! knows you're not sending it *from* Yahoo.com. Does your domain accept emails? Does it work if you send from an account within your own domain?
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

So.....

When I send mail from Horde Mail on my server
==Message to yahoo is not delivered
==Message to gmail is delivered

I can accept emails.

Does that mean my servers SMTP address/domain is blacklisted?

EDIT: Did some more testing. Created a mail account on another one of my domains on the same IP, email still doesn't go through to Yahoo but does to Gmail.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Is it the same email you're trying to send? Maybe the email content is sniffed at by Yahoo. If Horde can't send to Yahoo and your other domain still doesn't work I'd be looking at your email wording. Words like "Hey <user>" and "FREE something" make emails look spammy.
rotwyla98
Forum Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:54 pm

Post by rotwyla98 »

well.. its definitely my servers ip.

I fixed up the message body.
I copied all the code to another server and it sent email successfully to gmail, yahoo, and hotmail.
Try on mine, doesn't work.

Thanks for all of your help.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Would you like to PM me your IP? I may be able to help you figure out the problem and offer some guidance for correcting it. Sometimes the stupidest things can cause huge problems. No promises though :)
Post Reply