Open Colt94 opened 4 years ago
Hello Colt, thank you for posting this issue. I am facing the same problem, the android version works like a charm yet ios version email sender is not prompting to open the mailing apps.
Some Issue here
`[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: PlatformException(not_available, No email clients found!, null)
I have the same problem in IOS: the message I recived is : PlatformException(not_available, No email clients found!, null)
Any solutions?
I have this issue on iOS. Any news?
We have the same issue on iOS 14...
Same with iOS 13. Any solution yet?
on ios not working. No email clients found!
I see how far back this thread goes, but for what it's worth, it's now January 2022 and this issue appears to be persistent. Android works fine after making the recommended change to AndroidManifest.xml, but iOS still gives the same error of "no email clients found". Anyone figure this out yet? Is it some kind of permissions issue? Something in the Info.plist?
Seems there has been no fix. Is there project still actively maintained?
For the error No email clients found!
- this plugin does not work in an iOS simulator, because the simulator does not have an email client, plugin works only on real devices. Maybe that is the issue?
@sidlatau it's not working on iPhone 7+ (iOS 13.3.1). I'm getting PlatformException(not_available, No email clients found!, null, null)
but there are a default client and Gmail installed. Maybe it's expecting some default app to be configured (not sure it could be done on iOS13)
Reproducible on an iPhone 13 Pro with iOS 16.6, and I have repro steps! @sidlatau 100% reproducible when the iOS mail app is not logged in. Once logged in, I saw the new mail message modal pop up. The iPhone has Gmail installed/logged in, and the user's expectation would be for their preferred email client to open. Example: https://stackoverflow.com/a/55765362/2337925 If it's not possible, then IMHO it's a good idea to include a utility function to check whether the iOS Mail app can be opened.
For the error
No email clients found!
- this plugin does not work in an iOS simulator, because the simulator does not have an email client, plugin works only on real devices. Maybe that is the issue?
It's also occuring on real devices.
This is occurring on a physical iPhone (one of my users' devices, iOS 17.x). The user reports that they uninstalled the Apple Mail app. They have the Gmail app installed, but the flutter_email_sender
plugin does not seem to be able to send mail via Gmail.
This exception is thrown when MFMailComposeViewController.canSendMail()
returns false
which happens when there is no account set up to send mail on the device:
Apparently also if Gmail is configured as default, the same error occurs, even if the Apple Mail app is installed:
https://forums.developer.apple.com/forums/thread/653146?answerId=645928022#645928022
It seems to me that the solution is to catch this PlatformException
, and then on failure try using url_launcher
instead. Something like this:
Future<void> sendEmail(Email email) async {
try {
await FlutterEmailSender.send(email);
} catch (e, s) {
final recipients = Uri.encodeComponent(email.recipients.join(','));
final subject = Uri.encodeComponent(email.subject);
final body = Uri.encodeComponent(email.body);
final url = Uri.parse('mailto:$recipients?subject=$subject&body=$body');
var success = false;
try {
if (await canLaunchUrl(url)) {
success = await launchUrl(url);
}
} catch (e2) {
logError(error: e2, message: 'Could not launch email url');
}
if (!success) {
logError(error: e, message: 'Could not open email app');
reportToCrashylitics(e, s);
showSnackBar(
'Could not open email app'
);
}
}
}
@lukehutch
any solution for sending files in mail ? because url_launcher doesn't allow this feature...
@GregUAs there may be a special URL parameter for attachment path, but it will be platform-specific if it's even available at all. I don't know how to look up the URL spec for either Android or iOS.
I am now getting this error when sending an email on my flutter app using my Iphone 6s (IOS 13.5.1). I suspect it has to do with the IOS update because it worked with previous IOS versions. Anyone else experiencing this issue? Using xcode 11.
2020-06-17 11:38:59.448606-0500 Runner[398:16848] [Common] [FBSSystemService][0x7292] Error handling open request for com.apple.mobilemail: <NSError: 0x2831d8960; domain: FBSOpenApplicationServiceErrorDomain; code: 1 (RequestDenied); reason: "The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Un-trusted clients may not open applications in the background")."> { userInfo = { FBSOpenApplicationRequestID = 0x7292; } underlyingError = <NSError: 0x2831d8bd0; domain: FBSOpenApplicationErrorDomain; code: 3 (Security); reason: "Un-trusted clients may not open applications in the background.">; } 2020-06-17 11:38:59.448870-0500 Runner[398:17071] [General] #MailServices <MSAccounts: 0x282b4eb00> (0) : <connection: 0x280bebb40> failed to send message <dictionary: 0x281aaea60> NSError Domain=MailServices Code=2 2020-06-17 11:39:00.305431-0500