Hello everyone,
using v4b4 I thought of automatically switch transport from smtp to mail() in case the message can't be delivered by smtp. Testing it I assumed that wrong smtp login information would be a possible simulation of smtp failure.
I was surprised to see that the script "waited" around 15seconds before returning that the mail couldnt be delivered by smtp. I guess this is the desired behaviour and that there will be good reasons for it, but somehow I don't like it.
Is it possible to set this timeout to a lower value (I'd set it around 1s I guess) or am I trying something stupid anyway and there would be some kind of best practice for my problem? I was alreading reading something on this forum covering similar approaches but not exactly what I was trying to do.
Thank you very much in advance, greetings
Invalid smtp data => change timeout time?
Moderators: Chris Corbyn, General Moderators
Re: Invalid smtp data => change timeout time?
Swift_Transport_EsmtpTransport::setTimeout ????
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Invalid smtp data => change timeout time?
What did you actually do? Wrong username and password but correct SMTP server should be almost instant. Wrong SMTP server could cause severe hangs but this is nothing to do with Swift, it's to do with how your network responds to domain name lookups. If domain name resolution takes a long time before deciding the domain does not exist, then you will get a hang.
Could you please elaborate on the actual way in which you did this? Was it username/password based or was it host-based?
Could you please elaborate on the actual way in which you did this? Was it username/password based or was it host-based?
Re: Invalid smtp data => change timeout time?
@xdecock: thank you, I will test it as soon as I get home to my working machine
@ Chris: I cant tell 100% sure as I dont have access to the code right now, but I was just randomly inserting some values into my configuration, so its very likely I changed the server as well, thank you for your explaination.
@ Chris: I cant tell 100% sure as I dont have access to the code right now, but I was just randomly inserting some values into my configuration, so its very likely I changed the server as well, thank you for your explaination.
Re: Invalid smtp data => change timeout time?
Unfortunately the delay also appears when only the password is wrong.
The timeout is less, but still around 8-9 seconds.
@xdecock: can you provide me please with some information about this function? I was looking into the manual for v3 but found only something about setTimeout which doesn't seem to work with v4 (or I am using it wrong).
Thank you and greetings
Code: Select all
Swift_SmtpTransport::newInstance('domain.com', 25)
->setUsername('info@domain.com')
->setPassword('wrong_password');@xdecock: can you provide me please with some information about this function? I was looking into the manual for v3 but found only something about setTimeout which doesn't seem to work with v4 (or I am using it wrong).
Thank you and greetings
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Invalid smtp data => change timeout time?
setTimeout() does work in v4. I just haven't documented it yet.
It sounds as though your hang is in the time it takes to connect with the SMTP server. Do you have the details of the server?
It sounds as though your hang is in the time it takes to connect with the SMTP server. Do you have the details of the server?
Code: Select all
Swift_SmtpTransport::newInstance('domain.com', 25)
->setUsername('info@domain.com')
->setPassword('wrong_password')
->setTimeout(5);Re: Invalid smtp data => change timeout time?
Chris Corbyn wrote:Ok, I've found what's happening.
This server supports three different ways to authenticate (PLAIN, LOGIN, CRAM-MD5). When you put the wrong username and password the SMTP server hangs for a second or so while it tries to authenticate you... then it fails.
Now, Swift Mailer doesn't give up (by design) if authentication fails using one authentication mechanism. Instead, it tries again using a different one... until it's tried all possible methods and decides it can't authenticate.
In this case that's adding 3-4 seconds overhead since the server is pausing while Swift tries using each of PLAIN, LOGIN and CRAM-MD5. This is not easily avoidable.