2012-06-06 17 views
5

Uygulamamda smtp sunucusu kullanarak e-posta gönderebiliyorum, çünkü doğru e-posta kimliğimi ve şifremi girdim. ama gmail veya yahoo hesap bilgilerimi girdiğimde postaları gönderemiyorum. RöleHost = @ "smtp.gmail.com" ayarlı olarak ; sonra da posta gönderemiyorum.iphone?

Lütfen bana bu konuda yardımcı olun. Ayrıca kaynak kodu https://github.com/kailoa/iphone-smtp Kendi SMTP sunucusu kullanarak müthiş kod duyabiliyorum

-(void)sendEMAIL{ 

    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init]; 

    testMsg.fromEmail = str_uname; 
    NSLog(@"str_Uname=%@",testMsg.fromEmail); 

    testMsg.toEmail = str_info; 

    NSLog(@"autoemail=%@",testMsg.toEmail); 

    testMsg.relayHost = @"smtp.gmail.com"; 

    testMsg.requiresAuth = YES; 

    testMsg.login = str_uname; 
    NSLog(@"autoelogin=%@",testMsg.login); 

    testMsg.pass = str_password; 
    NSLog(@"autopass=%@",testMsg.pass); 

    testMsg.subject = @"Schedule Sms And Email"; 

    testMsg.wantsSecure = YES; 

    NSString *sendmsg=[[NSString alloc]initWithFormat:@"%@",str_info2]; 
    NSLog(@"automsg=%@",sendmsg); 

    testMsg.delegate = self; 

    NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey, 
          sendmsg, kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil]; 

    testMsg.parts = [NSArray arrayWithObjects:plainPart,nil]; 
    [testMsg send]; 
} 

-(void)messageSent:(SKPSMTPMessage *)message{ 
    [message release];  
} 

-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{ 
    [message release]; 
} 
+0

problem, gmail yol-ve yahoo kendi SMTP hizmetleri için özel doğrulama kullanır. – CarlJ

cevap

-1

bunun içinde yahoo, gmail, hotmail vb röle ana yönetebilir

NSArray *arr1 = [fromEmail componentsSeparatedByString:@"@"]; 
NSArray *arr2 = [[arr1 objectAtIndex:1] componentsSeparatedByString:@"."]; 

if ([arr2 containsObject:@"gmail"]) { 
    smtp_message.relayHost = @"smtp.gmail.com"; 
} 
else if ([arr2 containsObject:@"yahoo"]) { 
    smtp_message.relayHost = @"smtp.mail.yahoo.com"; 
} 
else if ([arr2 containsObject:@"hotmail"] || [arr2 containsObject:@"live"]) { 
    smtp_message.relayHost = @"smtp.live.com"; 
} 
else 
{ 
    NSString *smtpRelay = [[NSString alloc]init]; 
    smtpRelay = [NSString stringWithFormat:@"smtp.%@.com",[arr2 objectAtIndex:0]]; 
     smtp_message.relayHost = smtpRelay; 
}