This pull request introduces a new function named canSend to the flutter_email_sender package. This function helps developers determine if the device is currently capable of sending emails.
Motivation:
On iOS devices, users need to have a default email app installed (e.g., Apple Mail) to send emails through the flutter_email_sender package. Without an email app, sending emails will fail. This new function provides a way to check compatibility before attempting to send an email, improving the user experience.
Implementation:
A new function named canSend() is added to the FlutterEmailSender class.
This function utilizes platform-specific checks to determine if a compatible email app is installed.
On iOS, it can potentially leverage a framework like MessageUI to check for available mail services.
On Android, the logic might involve checking for installed email apps or mail intent capabilities.
The function should return a bool value indicating whether the device can send emails.
Example Usage:
import 'package:flutter_email_sender/flutter_email_sender.dart';
Future<void> sendEmail() async {
if (await FlutterEmailSender.canSend()) {
// Proceed with email sending logic
final email = Email(
senderName: "Your Name",
senderAddress: "your_email@example.com",
recipients: ['recipient1@example.com', 'recipient2@example.com'],
subject: 'Your Email Subject',
body: 'Your Email Body',
);
await email.send();
} else {
// Inform the user that email cannot be sent on this device
print("This device cannot send emails. Please install an email app.");
}
}
Feedback:
We welcome any feedback or suggestions on this pull request. Please feel free to leave comments or ask questions.
Description:
This pull request introduces a new function named
canSend
to theflutter_email_sender
package. This function helps developers determine if the device is currently capable of sending emails.Motivation:
On iOS devices, users need to have a default email app installed (e.g., Apple Mail) to send emails through the
flutter_email_sender
package. Without an email app, sending emails will fail. This new function provides a way to check compatibility before attempting to send an email, improving the user experience.Implementation:
canSend()
is added to theFlutterEmailSender
class.MessageUI
to check for available mail services.bool
value indicating whether the device can send emails.Example Usage:
Feedback:
We welcome any feedback or suggestions on this pull request. Please feel free to leave comments or ask questions.