Page 1 of 1

Can I have both an SMTP and Sendmail connection and choose?

Posted: Mon Feb 04, 2008 3:46 pm
by Flurrywinde
My site, http://www.playbyweb.com, is an online roleplaying play-by-post site, and it sends people the new posts in a nightly cron job. We currently use Swiftmailer's Sendmail connection. Yahoo has been deferring some of these e-mails for up to four days, and sometimes they never arrive at all. (I think it's because I'm on a shared host which has a poor e-mail reputation rating.)

To solve this, I tried using Gmail's SMTP server, but then the e-mails were being rejected by Hotmail (though they seemed to get through to Yahoo).

If there's a way to use the Gmail SMTP with Hotmail, let me know, but what I was thinking I have to do is set up my script to use the Gmail SMTP for only the Yahoo addresses and Sendmail for everyone else. Is this possible?

Also, I just read in the docs that Gmail only allows 50 at a time. How can I deal with that? Do I merely have to disconnect and reconnect?

close() is gone in version 3. Is there a new name now?

Finally, I've noticed that isConnected(), which I used in version 2, is also gone. How do I know if a connection failed?

Re: Can I have both an SMTP and Sendmail connection and choose?

Posted: Mon Feb 04, 2008 7:54 pm
by Chris Corbyn
Flurrywinde wrote:My site, http://www.playbyweb.com, is an online roleplaying play-by-post site, and it sends people the new posts in a nightly cron job. We currently use Swiftmailer's Sendmail connection. Yahoo has been deferring some of these e-mails for up to four days, and sometimes they never arrive at all. (I think it's because I'm on a shared host which has a poor e-mail reputation rating.)

To solve this, I tried using Gmail's SMTP server, but then the e-mails were being rejected by Hotmail (though they seemed to get through to Yahoo).
Sounds like your domain does not have a SPF record, or your SPF record conflicts with the use of Gmail.
If there's a way to use the Gmail SMTP with Hotmail, let me know, but what I was thinking I have to do is set up my script to use the Gmail SMTP for only the Yahoo addresses and Sendmail for everyone else. Is this possible?
It is, by use of a plugin, but I'm not sure this is the solution you want to be using. Far too ad-hoc.
Also, I just read in the docs that Gmail only allows 50 at a time. How can I deal with that? Do I merely have to disconnect and reconnect?
No. Disconnecting a reconnectin won't help since Gmail appears to be timing how many emails you send over a period of time (presumably to combat abuse). The best solution is to use your own SMTP server (or sendmail) and to fix the issues which are causing you to be blocked as spam.
close() is gone in version 3. Is there a new name now?
disconnect() -- though version 4 is out soon and there will be more API changes.
Finally, I've noticed that isConnected(), which I used in version 2, is also gone. How do I know if a connection failed?
In version 3 you use a try/catch. When you instantiate Swift an exception will be thrown if the connection fails. This isn't going to change in version 4, though the name of the exception will do.

Re: Can I have both an SMTP and Sendmail connection and choose?

Posted: Mon Feb 04, 2008 9:34 pm
by Flurrywinde
The SPF record is:

v=spf1 ip4:74.50.5.131 a ~all

What would make it conflict with Gmail's SMTP server?

I agree that the best solution would be to use sendmail, but I don't think it will be possible to get Yahoo to stop deferring the e-mails. I'm on a shared server, so other people on the same ip might be sending spam. We already tried it, and it got better for a few days only.

Would something like this work?:

Code: Select all

$mailer1 = new Swift(new Swift_Connection_Sendmail);
$conn =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$conn->setUsername("me@gmail.com");
$conn->setPassword("mypassword");
$mailer2 =& new Swift($conn);
 
$mailer2->attachPlugin(new Swift_Plugin_AntiFlood(1, 10), "anti-flood"); // Limit to 360 e-mails per hour on the Gmail SMTP server (or is that still too much?) 
. . .
if(is_hotmail($email)) mailer2->send(. . .);
else mailer->send(. . .);
Thanks for the help!

Re: Can I have both an SMTP and Sendmail connection and choose?

Posted: Mon Feb 04, 2008 9:41 pm
by Chris Corbyn
The SPF record looks fine if that's your server IP :) Maybe your host's server is in a blacklist?

Your solution of creating two swift instances will work fine yes... they are completely separate instances and won't conflict.

Re: Can I have both an SMTP and Sendmail connection and choose?

Posted: Tue Feb 05, 2008 3:01 am
by Flurrywinde
Yup, that's the ip. I checked at senderscore.org, and we're not on a blacklist. However, according to senderscore, the reputation of that ip is kinda low, so I think that's why Yahoo treats the e-mail as second class. Price you pay for cheap hosting, I guess.

I'll try the two instances idea. It's ad hoc, yes, but not too hard to implement and the only solution I can think of other than ones that cost money.

On another subject, I found this in the documentation:

$swift->log->enable();
echo implode(" ,", $swift->log->getFailedRecipients());

Is this how it's still done? In another part of the docs, logging is done with $log =& Swift_LogContainer::getLog();

Will failed recipients show up in $log->dump(true)? Or should I do $log->getFailedRecipients()?

Re: Can I have both an SMTP and Sendmail connection and choose?

Posted: Tue Feb 05, 2008 3:33 am
by Chris Corbyn
Flurrywinde wrote:On another subject, I found this in the documentation:

$swift->log->enable();
echo implode(" ,", $swift->log->getFailedRecipients());

Is this how it's still done? In another part of the docs, logging is done with $log =& Swift_LogContainer::getLog();

Will failed recipients show up in $log->dump(true)? Or should I do $log->getFailedRecipients()?
Thanks for brining this to my attention. Using the log container is how it's done. Accessing $swift->log was in older versions... I thought I'd fixed up all the docs but obviously not :)