test55dev / skpsmtpmessage

Automatically exported from code.google.com/p/skpsmtpmessage
0 stars 0 forks source link

messageFailed Delegate Fails to Fire When Sending Email To Invalid Gmail Address #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a message with the follow parameters:

    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
    testMsg.fromEmail = @"no-reply@email.com";
    testMsg.toEmail = @"sdfasdfsdfdf@gmail.com";
    testMsg.relayHost = @"aspmx.l.google.com";
    testMsg.requiresAuth = NO;
    testMsg.subject = @"test message";

2. The server will respond with a user not found 550 error
3. The messageFailed delegate is never raised.

What is the expected output? What do you see instead?
1.The messageFailed delegate should be raised.

Please provide any additional information below.
1. The "aspmx.l.google.com" server is a valid incoming SMTP server and does
not require authentication.

It appears that the reason this happens is that there is no catch for a 550
error in the kSKPSMTPWaitingToReply state in the parseBuffer method.

Adding a 550 error catch to the kSKPSMTPWaitingToReply state appears to fix
the problem. Following is a snippet of the code I used to fix the problem:

case kSKPSMTPWaitingToReply:
                {
                    if ([tmpLine hasPrefix:@"250 "])
                    {
                        sendState = kSKPSMTPWaitingForEnterMail;

                        NSString *dataString = @"DATA\r\n";
                        NSLog(@"C: %@", dataString);

CFWriteStreamWriteFully((CFWriteStreamRef)outputStream, (const uint8_t
*)[dataString UTF8String], [dataString
lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
                        [self startShortWatchdog];
                    }
                    else if ([tmpLine hasPrefix:@"530 "])
                    {
                        error =[NSError errorWithDomain:@"SKPSMTPMessageError" 
                                                   code:kSKPSMTPErrorNoRelay 
                                               userInfo:[NSDictionary
dictionaryWithObject:@"relay rejected - server probably requires auth" 

         forKey:NSLocalizedDescriptionKey]];
                        encounteredError = YES;
                    }
                    else if ([tmpLine hasPrefix:@"550 "])
                    {
                        error =[NSError errorWithDomain:@"SKPSMTPMessageError" 

code:kSKPSMTPErrorInvalidMessage 
                                               userInfo:[NSDictionary
dictionaryWithObject:@"error sending message" 

         forKey:NSLocalizedDescriptionKey]];
                        encounteredError = YES;
                    }
                    break;
                }

Original issue reported on code.google.com by jheising on 5 Feb 2009 at 1:39

GoogleCodeExporter commented 9 years ago
Please submit a properly formatted patch for inclusion.

Original comment by ibaird@gmail.com on 11 Feb 2009 at 1:21

GoogleCodeExporter commented 9 years ago
Where do I submit a patch?

Original comment by jheising on 11 Feb 2009 at 6:23

GoogleCodeExporter commented 9 years ago
I added your snippet. Fixed in latest.

Original comment by ibaird@gmail.com on 20 Feb 2009 at 3:36