Sagar Kothari avatar

๐Ÿ“ง Send Email from ๐Ÿ“ฒ Mobile-app using Flutter ๐Ÿง‘โ€๐Ÿ’ป

sagarkothari88

Published: 07 Nov 2022 โ€บ Updated: 07 Nov 2022๐Ÿ“ง Send Email from ๐Ÿ“ฒ Mobile-app using Flutter ๐Ÿง‘โ€๐Ÿ’ป

๐Ÿ“ง Send Email from ๐Ÿ“ฒ Mobile-app using Flutter ๐Ÿง‘โ€๐Ÿ’ป

image
source

Step 1

Open Terminal & navigate to your project directory.

Step 2

Add dependencies by running following command.

flutter pub add flutter_email_sender
flutter pub add url_launcher

Step 3

  • You can add following code snippet
  • It could be anywhere.
  • Ideally, you can put it on a button-press event.
  • If you are putting it inside a method, make sure you mark the function as async
final Email email = Email(
  body: 'I want to send email and This is where I add email body',
  subject: 'Email subject goes here',
  recipients: ['some-email@gmail.com'],
  isHTML: false,
);
try {
  // this will open native email composer
  await FlutterEmailSender.send(email);
} catch (e) {
  // upon failure (if no email configured)
  // we'll try to launch email composer with URL scheme
  var data = Uri.encodeFull(
      "subject=Email subject goes here&body=I want to send email and This is where I add email body");
  var url =
      Uri.parse('mailto:some-email@gmail.com?$data');
  launchUrl(url);
  log('Something went wrong ${e.toString()}');
}
  1. For Android, you may have to add following lines in AndroidManifest.xml file.
<manifest package="com.mycompany.myapp">
  <queries>
    <intent>
      <action android:name="android.intent.action.SENDTO" />
      <data android:scheme="mailto" />
    </intent>
  </queries>
</manifest>

That's it. You're all set.
Hope that, above details were helpful to you.

image
source


Who am I?


Support Me Back ๐Ÿ™

Support 3Speak

Download Android AppVote me as Hive WitnessDownload iOS App
Join 3Speak DiscordSetup Encoder NodeVote for 3Speak Proposal
Earn Money using HoneyGainGet a server

Cheers
Have a good one

---

Posted from 3Speak iOS App for 3Speak
Developed and maintained by sagarkothari88@sagarkothari88

Leave ๐Ÿ“ง Send Email from ๐Ÿ“ฒ Mobile-app using Flutter ๐Ÿง‘โ€๐Ÿ’ป to:

Written by

App Developer on Hive - Distriator, Check in With XYZ, 3Speak, HiveSuite.app.

Read more #hive-181436 posts


Best Posts From Sagar Kothari

We have not curated any of sagarkothari88's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Sagar Kothari