1

I used SKPSMTPMessage in my iPhone application. Problem is with multiple recipients. I just need to send email to two recipient.

I'm using the following code:

-(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 = @"[email protected]";
//  testMsg.toEmail = phone;
testMsg.toEmail=@"[email protected];

testMsg.relayHost = @"smtp.nman.co.uk";
testMsg.requiresAuth = YES;
testMsg.login = @"[email protected]";
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;
}

Anyone knows how can i send email to 2 recipient

ChikabuZ
  • 10,031
  • 5
  • 63
  • 86
Mann
  • 5,477
  • 6
  • 45
  • 57

1 Answers1

3

There is the heck solution for this

First Create the recipientsArray which contains your recipients

NSArray* recipientsArray = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]",nil];

Call you sendEmail method

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

Then define your sendEmail method:

-(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 = @"[email protected]";

    testMsg.toEmail = _toEmailAddress;
    testMsg.relayHost = @"smtp.nman.co.uk";
    testMsg.requiresAuth = YES;
    testMsg.login = @"[email protected]";
    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;
}
Praveen-K
  • 3,401
  • 1
  • 23
  • 31