加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iPhone使用smtp服务器发送电子邮件?

发布时间:2020-12-14 19:07:01 所属栏目:百科 来源:网络整理
导读:在我的应用程序中,我能够使用smtp服务器发送电子邮件,因为我输入了正确的电子邮件ID和密码. 但当我输入我的Gmail或雅虎帐户详细信息时,我无法发送邮件. 因为我设置了relayHost = @“smtp.gmail.com”;然后我也无法发送邮件. 请帮我解决这个问题. 以下是我的
在我的应用程序中,我能够使用smtp服务器发送电子邮件,因为我输入了正确的电子邮件ID和密码.
但当我输入我的Gmail或雅虎帐户详细信息时,我无法发送邮件.
因为我设置了relayHost = @“smtp.gmail.com”;然后我也无法发送邮件.

请帮我解决这个问题.

以下是我的代码:

-(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];
}

解决方法

你也可以从听到 https://github.com/kailoa/iphone-smtp源代码使用smtp服务器它是一个很棒的代码.

http://iphonesdksnippets.com/send-email-with-attachments-on-iphone.html使用此链接也很好….只需从那里下载框架并使用该代码.它也很好.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读