我使用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];
注意:这是完美的代码。自上周以来,它显示错误。
答案 0 :(得分:0)
尝试
NSMutableArray
* msg_parts = [[NSMutableArray alloc]initWithArray
:array];
代替NSMutableArray * msg_parts = [NSMutableArray array];
答案 1 :(得分:0)
请检查以下详细信息是否有效,
msg.login = @"123456789@gmail.com";
msg.pass = @"123456789//";