【问题标题】:iOS MFMailComposeViewController sent mail but not receivediOS MFMailComposeViewController 发送邮件但未收到
【发布时间】:2015-06-19 12:47:03
【问题描述】:

代码:

 if ([MFMailComposeViewController canSendMail]) {

     MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
     mail.mailComposeDelegate = self;
     [mail setSubject:@"Sample Subject"];
     [mail setMessageBody:@"Here is some main text in the email!" isHTML:NO];
     [mail setToRecipients:@[@""]];

     [self presentViewController:mail animated:YES completion:NULL];
 } else {
     NSLog(@"This device cannot send email");
 }


- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result
{
    switch (result) {
        case MessageComposeResultCancelled:
            break;

        case MessageComposeResultFailed:
        {
            UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to send SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [warningAlert show];
            break;
        }

        case MessageComposeResultSent:
            break;

        default:
            break;
    }

    [self dismissViewControllerAnimated:YES completion:nil];
}

我使用 MFMailComposeViewController 发送邮件。 即使我收到成功消息,收件人也没有收到我的邮件。

我错过了什么?

【问题讨论】:

  • 你是在真机上测试吗?或模拟器,因为要检查功能工作,您必须在设备上进行测试。
  • 我在设备上测试了它。但接收器没有收到它..
  • 你检查你发送的邮件了吗??
  • 我查过了。它是空的..
  • 代码格式和拼写

标签: ios iphone mfmailcomposeviewcontroller


【解决方案1】:

Errrr,真的吗?

MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
. . .
[mail setToRecipients:@[@""]];

您还没有设置“收件人”电子邮件地址,并且您抱怨电子邮件没有到达..?

试试这个:硬编码一个电子邮件地址,使用“arrayWithObject”,看看现在是否发送电子邮件:

NSString *emailAddress = @"mike@isomewhere.com";

MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
. . . 
[mail setToRecipients:[NSArray arrayWithObject:emailAddress]];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-15
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多