0

我正在使用SKPSMTPMessage文件发送邮件,但在发送电子邮件时显示以下错误

 Error Domain=SKPSMTPMessageError 
 Code=535 "Invalid username or password." 
 UserInfo=0xaa2de20 {NSLocalizedRecoverySuggestion=Go to Email Preferences in the application and re-enter your username and password., 
                     NSLocalizedDescription=Invalid username or password.}

我应该在哪里更改用户名和密码?代码如下:

SKPSMTPMessage *msg = [[SKPSMTPMessage alloc] init];
msg.fromEmail = @"123456789s@gmail.com";
msg.toEmail = to;
msg.relayHost = @"smtp.gmail.com";
msg.requiresAuth = YES;
msg.login = @"123456789@gmail.com";
msg.pass = @"123456789//";
msg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
msg.subject = [NSString stringWithFormat:@"Check Out %@ by Docstoc", self.navigationItem.title];
msg.delegate = self;

NSMutableArray *msg_parts = [NSMutableArray array];

NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys:
                                 @"text/html\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey,
                                 [message stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey,                                         
                                 nil];
[msg_parts addObject:plain_text_part];
msg.parts = msg_parts;

[msg send];  

注意:这是完美的工作代码。自上周以来,它一直在显示错误。

4

2 回答 2

0

请检查您的以下详细信息是否有效,

msg.login = @"123456789@gmail.com";
msg.pass = @"123456789//";
于 2014-08-26T07:02:18.693 回答
0

尝试

NSMutableArray*msg_parts = [[ NSMutableArray alloc]initWithArray:array];

而不是 NSMutableArray *msg_parts = [NSMutableArray 数组];

于 2013-02-07T11:57:23.657 回答