timed out when trying to connect to different SMTP servers
Moderators: Chris Corbyn, General Moderators
timed out when trying to connect to different SMTP servers
Firstly I have to say swiftmailer seems like a very useful package, if I could get it to work.
I would really love some help or feedback on why I cannot use swiftmailer to connect to an outgoing SMTP server.
I keep getting the following error message when trying to connect to bunch of different local SMTP servers:
"Connection to the given MTA failed. The Connection Interface said: Connection timed out"
I used the same host SMTP as where the swiftmailer script is called. (Script is hosted on mweb.co.za and SMPT used is smtp.mweb.co.za)
I have also tried the SMTP server of my local ISP, but get the same error message.
Not sure what to do to solve this issue, i'm trying to learn about mailing but my knowledge is still quite limited.
SendMail works fine with the server but I plan to send thousands of emails and would prefer to use SMTP to do this.
If anyone has any suggestions it would be greatly appreciated.
Thank you.
I would really love some help or feedback on why I cannot use swiftmailer to connect to an outgoing SMTP server.
I keep getting the following error message when trying to connect to bunch of different local SMTP servers:
"Connection to the given MTA failed. The Connection Interface said: Connection timed out"
I used the same host SMTP as where the swiftmailer script is called. (Script is hosted on mweb.co.za and SMPT used is smtp.mweb.co.za)
I have also tried the SMTP server of my local ISP, but get the same error message.
Not sure what to do to solve this issue, i'm trying to learn about mailing but my knowledge is still quite limited.
SendMail works fine with the server but I plan to send thousands of emails and would prefer to use SMTP to do this.
If anyone has any suggestions it would be greatly appreciated.
Thank you.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: timed out when trying to connect to different SMTP serve
Sounds like your host is blocking traffic, or the remote server is blocking your connection.
Do you have shell access to the server? If so, try this:
If you don't have telnet, just try:
Swift does nothing more magical than opening a socket to the remote server 
Do you have shell access to the server? If so, try this:
Code: Select all
-$ telnet <server-name-here> 25
#wait and see if you get a response nowCode: Select all
$sock = fsockopen("server-name", 25, $errno, $errstr, 10);
var_dump($sock);
echo "<br />Error number: $errno";
echo "<br />Error message: $errstr";thanx for the reply.
I unfortunately don't have have shell access to the remote server, but I tried your code and got the following:
bool(false)
Error number: 110
Error message: Connection timed out
i tried using
$sock = fsockopen("smtp.mweb.co.za", 25, $errno, $errstr, 10);
and
$sock = fsockopen("mweb.co.za", 25, $errno, $errstr, 10);
and got the error for both.
I then thought about the returned headers from a returned email I received using the mail() function, and found a different domain:
Received: from mercury.mweb.net ([196.2.16.75] helo=mercury.mweb.co.za)
by remail.mweb.net with esmtp (Exim 4.60)
id 1H4yqy-0003Ci-VF
for <****@****.net>; Thu, 11 Jan 2007 14:16:21 +0200
So I decided to try remail.mweb.net and it seems to be working now.
Thanx a lot for the help!
Is it a good idea to trust this server to send many thousand emails?
I unfortunately don't have have shell access to the remote server, but I tried your code and got the following:
bool(false)
Error number: 110
Error message: Connection timed out
i tried using
$sock = fsockopen("smtp.mweb.co.za", 25, $errno, $errstr, 10);
and
$sock = fsockopen("mweb.co.za", 25, $errno, $errstr, 10);
and got the error for both.
I then thought about the returned headers from a returned email I received using the mail() function, and found a different domain:
Received: from mercury.mweb.net ([196.2.16.75] helo=mercury.mweb.co.za)
by remail.mweb.net with esmtp (Exim 4.60)
id 1H4yqy-0003Ci-VF
for <****@****.net>; Thu, 11 Jan 2007 14:16:21 +0200
So I decided to try remail.mweb.net and it seems to be working now.
Thanx a lot for the help!
Is it a good idea to trust this server to send many thousand emails?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I can't offer that help I'm afraid
Your host will be able to tell you what SMTP server to use, although it looks ok to me, they may change things around often.
Usually looking up the MX record of the domain your host runs on will give to the answer, but it's possible to route incoming and outgoing mail via different servers. Bottom line, ask your host
Usually looking up the MX record of the domain your host runs on will give to the answer, but it's possible to route incoming and outgoing mail via different servers. Bottom line, ask your host
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You need a command line tool called "dig". I belive there will be online services that offer dig queries.decipher wrote:By my "host", do you mean my ISP's smtp server, or the host where the script is hosted SMTP server?
I tried doing a whois on the domain but it did not give any smtp information, how would i do a MX record?
I meant the SMTP server of the host your script is on
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Better to use cron. I provided that plugin because some people don't like cron for whatever reasondecipher wrote:Thankyou for all your help, I believe I am finally getting somewhere.:)
I remember now I would like to ask one last question..
To send large batch emails using SMTP (say 6000), would be better to use cron to send limited emails per batch, or using the anti flood plugin to send all 6000 emaiils?
Sweet, thanx for clearing that up.
I have done a lot of testing with mail() and with my remote server it can take anywhere from 2sec to 64sec to send a batch of 30 emails.
For my test i was simply outputting javascript timeout code to wait 5 sec after sending the 30 mails, and then reload the page..
For the formal mass mailing, i will be using cron, and I wanted to know Is using SMTP a lot faster than mail(). Would it send 50 emails with no attachments fairly quickly?
Can this combination of cron and anti flood plugin be used to send mailings of up to 100 000 emails?
I have done a lot of testing with mail() and with my remote server it can take anywhere from 2sec to 64sec to send a batch of 30 emails.
For my test i was simply outputting javascript timeout code to wait 5 sec after sending the 30 mails, and then reload the page..
For the formal mass mailing, i will be using cron, and I wanted to know Is using SMTP a lot faster than mail(). Would it send 50 emails with no attachments fairly quickly?
Can this combination of cron and anti flood plugin be used to send mailings of up to 100 000 emails?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It varies hugely between linux servers and windows servers. I'll asssume linux.decipher wrote:Sweet, thanx for clearing that up.
I have done a lot of testing with mail() and with my remote server it can take anywhere from 2sec to 64sec to send a batch of 30 emails.
For my test i was simply outputting javascript timeout code to wait 5 sec after sending the 30 mails, and then reload the page..
For the formal mass mailing, i will be using cron, and I wanted to know Is using SMTP a lot faster than mail(). Would it send 50 emails with no attachments fairly quickly?
Can this combination of cron and anti flood plugin be used to send mailings of up to 100 000 emails?
In which case, your answer is no, mail() will be faster than SMTP since linux server simply pass the mail to a local binary which queues it for sending when the server "gets time" to do it. With SMTP, the receiving server needs to listen to what you tell it and respond appropriately... it's like the two computers have a short conversation.
Advantages of Swift?
* Messages are far less likely to be blocked as spam
* The fact it uses SMTP allows to get know if the server really is sending the email, not just sticking it on the mail queue
* Some hosts restrict the number of emails you send per-hour via mail()
* Windows machine run slower with mail() - non-persistent connections yadda yadda yadda
Using the sendmail connection will be faster, and using the "NativeMail" connection will be comparable with the speed of mail() on either system.
i've just found out that using
will use php.ini SMTP setting, which in my case is localhost, which i assume defaults to the servers assigned smtp server.
This would have solved my problem from first post, doh!
Would appreciate if you had the time to answer my previous post.
Code: Select all
new Swift_Connection_SMTP(SWIFT_AUTO_DETECT);This would have solved my problem from first post, doh!
Would appreciate if you had the time to answer my previous post.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Using Sendmail "appears" faster because the mail gets whacked onto a queue locally. However, it still takes the same amount of time when it finally leaves the queue because currently the only standard way to deliver email is via the SMTP protocol, so the mail inevitably goes through the SMTP process at a later time. Your recipients will not see the mail any faster -- in fact, probably slower, but your script will end sooner. What do you want?decipher wrote:Linux ofcourse
Okay so using sendmail will be faster but is SMTP more reliable?
Would be a better option using sendmail with anti flood plugin and cron compared to SMTP?
Does the sendmail connection use a persistant connection compared to just looping through recipients and mail() 'ing it off?
The sendmail connection in Swift uses a persistent connection yes. It also talks in SMTP mode the a local binary on the server (not over TCP) rather than doing what mail() does and simply throwing emails at it with barely any feedback. This means if Sendmail rejects any recipients you can find out about it.... with mail() that's not true.
I'm speaking entire in a linux environment here; Windows uses a totally different mechanism for mail().
SMTP is more reliable if you want to know what happened with the emails you sent, but the Sendmail connection in Swift puts Sendmail into a special mode which speaks SMTP anyway.
If you use the SMTP connection you spread the work across two servers and therefore lower the load, but you have to account for the extra time used by network traffic.... but don't be fooled that the emails are taking longer to send because of this; the reality is that you're just watching them leave the queue sooner.
I did read somewhere that even mail() function uses smtp so thanx for clearing that up.. SMTP for outgoing mail.. I'm getting there! 
Okay so I have decided to use the sendmail instead, combined with anti-flood plugin and cron.
I guess the best way to find out which is best is to test and see for myself.. If sendmail is putting too much load on the server i will resort to straight SMTP connection.. I have a 4000 emails database but wish to eventually find a method to send up to 100 000.
Thanx for all the help man
Okay so I have decided to use the sendmail instead, combined with anti-flood plugin and cron.
I guess the best way to find out which is best is to test and see for myself.. If sendmail is putting too much load on the server i will resort to straight SMTP connection.. I have a 4000 emails database but wish to eventually find a method to send up to 100 000.
Thanx for all the help man