使用SKPSMTPMessage向2个收件人发送电子邮件

时间:2011-08-13 20:46:13

标签: iphone email-integration skpsmtpmessage

我在iPhone应用程序中使用了SKPSMTPMessage。问题在于多个收件人。我只需要向两个收件人发送电子邮件。

我正在使用以下代码:

-(void)sendEmail {

// create soft wait overlay so the user knows whats going on in the background.
[self createWaitOverlay];

//the guts of the message.
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"support@dsfaes.co.uk";
//  testMsg.toEmail = phone;
testMsg.toEmail=@"manjinderr@gmail.com;

testMsg.relayHost = @"smtp.nman.co.uk";
testMsg.requiresAuth = YES;
testMsg.login = @"support@man.co.uk";
testMsg.pass = @"nfsdxsdfswdrt";
testMsg.subject = @"The Confirmation";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!

// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
}

任何人都知道如何向2位收件人发送电子邮件

1 个答案:

答案 0 :(得分:3)

heck解决方案

首先创建包含收件人的recipientsArray

NSArray* recipientsArray = [NSArray arrayWithObjects:@"abc@abc.com",@"xyz@xyz.com",nil];

调用sendEmail方法

for(NSString* toEmailAddress in recipientsArray){
   [self sendEmail:toEmailAddress];
}

然后定义您的sendEmail方法:

-(void)sendEmail:(NSString*)_toEmailAddress {
    // create soft wait overlay so the user knows whats going on in the background.
    [self createWaitOverlay];

    //the guts of the message.
    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
    testMsg.fromEmail = @"support@dsfaes.co.uk";

    testMsg.toEmail = _toEmailAddress;
    testMsg.relayHost = @"smtp.nman.co.uk";
    testMsg.requiresAuth = YES;
    testMsg.login = @"support@man.co.uk";
    testMsg.pass = @"nfsdxsdfswdrt";
    testMsg.subject = @"The Confirmation";
    testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!

    // Only do this for self-signed certs!
  // testMsg.validateSSLChain = NO;
  testMsg.delegate = self;
}