sendMailWithHeaders never returns

Discussion of the EDMessage and EDCommon frameworks.

sendMailWithHeaders never returns

Postby allbabel » 03 Mar 2010, 13:43

Hi All,

I am using EDMessage to send an email in an application. It all works great until the user specifies an invalid port number. For example sending an email using smtp.gmail.com using port 465. The sendMailWithHeaders just blocks and doesn't timeout with any error. Basically the code goes like this:

EDMailAgent * mailAgent = [EDMailAgent mailAgentForRelayHostWithName:smtpServer port:port];
[mailAgent setUsesSecureConnections:ssl]; // ssl is YES
NSMutableDictionary *authInfo = [NSMutableDictionary dictionary];
[authInfo setObject:user forKey:EDSMTPUserName];
[authInfo setObject:password forKey:EDSMTPPassword];
[mailAgent setAuthInfo:authInfo];

NSMutableDictionary *headerFields = [NSMutableDictionary dictionary];
[headerFields setObject:to forKey:EDMailTo];
[headerFields setObject:user forKey:EDMailFrom];
[headerFields setObject:subject forKey:EDMailSubject];

// This blocks forever
[mailAgent sendMailWithHeaders:headerFields body:text andAttachments:attachmentList];

I have this running in a separate thread and I just want to know how I can work around this as this just blocks forever and the only way to escape is to kill the thread which isn't what I want to do. Is there a way to specify a timeout?

Thanks in advance
Andy
allbabel
 
Posts: 1
Joined: 03 Mar 2010, 13:34

Re: sendMailWithHeaders never returns

Postby erik » 18 Apr 2010, 15:36

I guess the firewall is dropping packets to "wrong" ports, but in that case there should be a timeout sooner or later. How long is "never" in your case? And where does the code actually hang? Can you provide a stack trace?
erik
 
Posts: 90
Joined: 10 Oct 2009, 15:22
Location: Hamburg, Germany

Re: sendMailWithHeaders never returns

Postby Jocelyn » 20 Oct 2010, 01:06

I am wondering if it is necessary to put the email send code into another thread. Sending email is just a part of my project and I don't want the whole thing to crash if something goes wrong. What approach is best?

Thanks.
Jocelyn
 
Posts: 2
Joined: 20 Oct 2010, 01:02


Return to ED Frameworks



cron