简体   繁体   English

iPhone使用smtp服务器向多个收件人发送电子邮件?

[英]Iphone to send email to multiple recipients using smtp server?

In my application i want to send email to multiple recipients. 在我的应用程序中,我想向多个收件人发送电子邮件。 i am able to send email to one person at a time and now i want to send email to multiple recipients. 我能够一次向一个人发送电子邮件,现在我想向多个收件人发送电子邮件。

i am having a nsmutable array *sNamesArr which content the data of the recipient. 我有一个nsmutable数组* sNamesArr,内容满足接收者的数据。 NSMutableArray *sNamesArr; NSMutableArray * sNamesArr;

following is m code: 以下是m代码:

-(void)sendEMAIL
{
    NSLog(@"Paused state100");
    [dictUser retain];



    //Auto code


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


    //testMsg.fromEmail = @"Lexi mobile";//nimit51parekh@gmail.com

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

//    str_info = [str_info stringByReplacingOccurrencesOfString:@"," withString:@""];
//    testMsg.toEmail = str_info;
//    NSLog(@"autoemail=%@",testMsg.toEmail);

    //str_info = [str_info stringByReplacingOccurrencesOfString:@"," withString:@""];

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

   // [self DeleteRowAfterSending];
    [self performSelector:@selector(DeleteRowAfterSending) withObject:nil afterDelay:5.0];
}

It appears that the SKPSMTPMessage class is limited to sending to a single address at a time. 看来,SKPSMTPMessage类仅限于一次发送到单个地址。 So it seems that you have three choices: 因此,您似乎有三个选择:

  1. Download the SKPSMTPMessage code and modify it to support a list of TO addresses. 下载SKPSMTPMessage代码并对其进行修改以支持TO地址列表。
  2. Write your own SMTP client library to send to multiple recipients. 编写您自己的SMTP客户端库,以发送给多个收件人。 If you know that your messages will not contain attachments and have predictable content then the task of writing an SMTP socket client will be easier. 如果您知道您的邮件将不包含附件且内容可预测,则编写SMTP套接字客户端的任务将更加容易。
  3. If your app is already talking to services that you control, add a service end-point to send the emails where the phone sends the content and recipients and the service does all of the SMTP work. 如果您的应用已经在与您控制的服务进行通讯,请添加服务端点以发送电子邮件,电话将在其中发送内容和收件人,并且该服务将完成所有SMTP的工作。

SKPSMTPMessage sends to the SMTP address all at once, and must send one by one. SKPSMTPMessage一次全部发送到SMTP地址,并且必须一次发送一次。

This link would be really helpful for you. 该链接对您真的很有帮助。

Send email to multiple recipients with SKPSMTPMessage? 使用SKPSMTPMessage向多个收件人发送电子邮件吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM