0

So I'm having a serious issue with this class...

Currently, when the user actually sends an email out, the ActivityIndicator shows... great!!! as well as the UI not being frozen... Thats cool!

Issue is, if the user pushes to another viewcontroller which actually dismisses the send email viewcontroller, the app crashes... I notice I have to wait until the SECOND "*** stopping watchdog ***" string has been logged... as well as this "S: 221 2.0.0 closing connection i16sm31117760pag.18 - gsmtp"

Heres the full log,

013-07-09 09:50:50.655 PowerOneApp[29380:c07] C: Attempting to connect to server at: smtp.gmail.com:25
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] S: 220 mx.google.com ESMTP nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] S: 250-STARTTLS
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] C: STARTTLS
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] S: 220 2.0.0 Ready to start TLS
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] Beginning TLSv1...
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:50:51.102 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] S: 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] C: AUTH PLAIN AGpzZXR0aW5nMzIARm9vdGJhbGwzMyE=
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] S: 235 2.7.0 Accepted
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] C: MAIL FROM:<jsetting32@icloud.com> BODY=8BITMIME
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] S: 250 2.1.0 OK nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] C: RCPT TO:<jsetting32@gmail.com>
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] S: 250 2.1.5 OK nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] C: DATA
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:53.220 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:53.220 PowerOneApp[29380:c07] S: 354  Go ahead nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:53.221 PowerOneApp[29380:c07] *** starting long watchdog ***
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] S: 250 2.0.0 OK 1373388654 nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] C: QUIT
2013-07-09 09:50:54.701 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:54.734 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:54.734 PowerOneApp[29380:c07] S: 221 2.0.0 closing connection nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:58.656 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.190 PowerOneApp[29380:c07] C: Attempting to connect to server at: smtp.gmail.com:25
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] S: 220 mx.google.com ESMTP i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:51:11.277 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.317 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] S: 250-STARTTLS
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] C: STARTTLS
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.320 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.320 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:51:11.354 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.354 PowerOneApp[29380:c07] S: 220 2.0.0 Ready to start TLS
2013-07-09 09:51:11.355 PowerOneApp[29380:c07] Beginning TLSv1...
2013-07-09 09:51:11.355 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:51:11.644 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] S: 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] C: AUTH PLAIN AGpzZXR0aW5nMzIARm9vdGJhbGwzMyE=
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.462 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] S: 235 2.7.0 Accepted
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] C: MAIL FROM:<jsetting32@icloud.com> BODY=8BITMIME
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.502 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] S: 250 2.1.0 OK i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] C: RCPT TO:<jsetting32@gmail.com>
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] S: 250 2.1.5 OK i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] C: DATA
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:13.102 PowerOneApp[29380:c07] Let us know about a broken feature
2013-07-09 09:51:13.289 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:13.289 PowerOneApp[29380:c07] S: 354  Go ahead i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:13.290 PowerOneApp[29380:c07] *** starting long watchdog ***
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] S: 250 2.0.0 OK 1373388674 i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] C: QUIT
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:14.792 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:14.793 PowerOneApp[29380:c07] S: 221 2.0.0 closing connection i16sm31117760pag.18 - gsmtp

Now, I "really fast" exit the view that sends the email and it continues to send the email, then I get this message *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType messageSent:]: unrecognized selector sent to instance 0xa0a8e50'

That occurs when I use [testMsg performSelectorOnBackgroundThread:@selector(send) withObject:nil];

But when I use [testMsg performSelectorOnMainThread:@selector(send) withObject:nil waitUntilDone:YES]; I get the same issue as the log statement as posted first...

Sorry for my horrible phrasing but I'm just a bit frustrated with this bug :(.

jsetting32
  • 1,632
  • 2
  • 20
  • 45

1 Answers1

1

I guess the bug doesn't lay in sending the mail via SMTP. It seems that the delegate-object has been release before the messageSent: delegate method is beeing called.

My suggestion would be to perform the SKPSMTPMessage send operation in the Application Delegate. If you don't want the SMTP Message send handle to be in the app-delegate, retain your delegate object until the mail has been sent or set the delegate of the SKSMTPMessage to nil, when the delegate object is beeing deallocated.

Hope it helps

NicTesla
  • 1,626
  • 5
  • 21
  • 35