by 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
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