问题
Is it possible to send email in iOS without relying on the default mail / messaging interface of the system? Does it really the same with messaging where you can not create your custom interface for message but to use the default interface of MFMessageComposerViewController?
回答1:
Take a look at this answer.
Locking the Fields in MFMailComposeViewController
If you follow the instructions you can create your own custom View then send email. Without having to use the default MFMessageCompserViewController .
回答2:
If you want to use the email account setup for the device, you'll need to use MFMessageComposerViewController
or a mailto:
url to open Mail.app.
回答3:
SendGrid library allows user to send email from an ios app without MFMailComposer https://sendgrid.com/blog/send-email-in-ios-with-new-sendgrid-library/
Here’s the basic code for how you can send email with iOS:
//create Email Object
sendgrid *msg = [sendgrid user:@"ApiUser" andPass:@"ApiKey"];
//set parameters
msg.subject = @"email subject";
msg.tolist = @[@"foo@bar.com", @"foo2@bar.com"];
msg.from = @"originalfoo@bar.com";
msg.text = @"hello world";
msg.html = @"<html><body><h1>hello world</h1></body></html>";
//adding unique arguments (Optional)
NSDictionary *uarg = @{@"customerAccountNumber":@"55555",
@"activationAttempt": @"1"};
[msg addCustomHeader:uarg withKey:@"unique_args"];
//adding categories (Optional)
NSString *replyto = @"billing_notifications";
[msg addCustomHeader:replyto withKey:@"category"];
//Image attachment (Optional)
[msg attachImage:self.photo];
//Send email through Web API Transport
[msg sendWithWeb];
来源:https://stackoverflow.com/questions/9012587/sending-email-without-using-mfmailcomposeviewcontroller