Email setup in my own iphone app
I am new to iphone app development, i have created my own app, i want to know whether we can setup the email address for our own app or we have to use on开发者_如何学Goly the email that was setup in the iphone. If we can please give me an idea of how to do it.
Thanks in Advance Akhil
Mails sent from within app will only use the default mail account in Settings.
EDIT: Here is a sample sendEmail() method:
-(IBAction) sendEmail{
if(![MFMailComposeViewController canSendMail]){
//show info msg to user
return;
}
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Hello"];
[controller setMessageBody:@"How are you?" isHTML:NO];
[controller addAttachmentData:UIImageJPEGRepresentation(myImage,0.8) mimeType:@"image/jpeg" fileName:@"fileName.jpg"];
[self presentModalViewController:controller animated:YES];
[controller release];
}
You will need the addAttachmentData
method for attachments.
You will also need to implement the didFinishWithResult method to discard the MFMail controller
-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult) result error:(NSError *) error{
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
Make sure your the class where you write these methos implements the < MFMailComposeViewControllerDelegate > protocol
Hope this helps!
You could use the SKPSMTPMessage framework for this. I've used it a few times, and it works OK. I would recommend using apple's method though
You can open sockets to any server / port you wish and perform whatever actions you want to take. If you run your own SMTP mail server, you could accept "emails" from your own applications pretty easily:
EHLO <some identifier>
MAIL FROM: <identifier@domain>
RCPT TO: <destination@domain>
DATA
email goes here
QUIT
See RFC 2821 for details.
精彩评论