0

iPhone アプリケーションで SKPSMTPMessage を使用しました。問題は複数の受信者にあります。2人の受信者にメールを送信するだけです。

私は次のコードを使用しています:

-(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人の受信者にメールを送信する方法を知っています

4

1 に答える 1

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;
}
于 2011-08-13T21:24:04.707 に答える