I am using MFMailComposeViewController so the user can email in app. Just like so:
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
[mail setToRecipients:[NSArray arrayWithObject:emailString]];
mail.mailComposeDelegate = self;
[self presentModalViewController:mail animated:YES];
I have noticed if an invalid email address is given to it it simply doesn't put it into the recipients field, is there anyway of me taking action of this happens? Or overriding this?
Thanks.
First try to validate your email Address. Use this code below
-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", stricterFilterString];
return [emailTest evaluateWithObject:checkString];
}
Pass your email string as argument to NSStringIsValidEmail: method. It will return YES if valid, NO otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With