Advertisement
Guest User

Untitled

a guest
May 4th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. - (IBAction)sendEmail:(id)sender {
  2. MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init];
  3.  
  4. MCOAddress *address = [MCOAddress addressWithDisplayName:@"Uplant Support" mailbox:@"noreply.uplant@gmail.com"];
  5. NSArray *to = [NSArray arrayWithObject:[MCOAddress addressWithDisplayName:@"Glenn Posadas" mailbox:@"admin@glennvon.com"]];
  6.  
  7. [[builder header] setFrom:address];
  8. [[builder header] setTo:to];
  9. [[builder header] setSubject:@"This is a nice subject"];
  10. [builder setHTMLBody:@"The motherloving body."];
  11.  
  12. NSData * data = [builder data];
  13.  
  14. MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
  15. [smtpSession setHostname:@"smtp.gmail.com"];
  16. [smtpSession setUsername:@"noreply.uplant@gmail.com"];
  17. [smtpSession setPassword:@"----"];
  18. [smtpSession setPort:465];
  19. [smtpSession setConnectionType:MCOConnectionTypeTLS];
  20.  
  21. MCOSMTPSendOperation *smtpSender = [smtpSession sendOperationWithData: data];
  22. [smtpSender start:^(NSError * _Nullable error) {
  23. NSLog(@"Error: %@", error.localizedDescription);
  24. }];
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement