📧 Send Email from 📲 Mobile-app using Flutter 🧑‍💻

in the-hive-mobile.app2 years ago (edited)

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: ['[email protected]'],
  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:[email protected]?$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

Sort:  

Yay! 🤗
Your content has been boosted with Ecency Points
Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for new Proposal
Delegate HP and earn more, by @sagarkothari88.

Discord Server.This post has been manually curated by @bhattg from Indiaunited community. Join us on our

Do you know that you can earn a passive income by delegating to @indiaunited. We share 100 % of the curation rewards with the delegators.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

Read our latest announcement post to get more information.

image.png

Please contribute to the community by upvoting this comment and posts made by @indiaunited.

Congratulations @sagarkothari88! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 9000 upvotes.
Your next target is to reach 10000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Check out the last post from @hivebuzz:

CBRS Hive Infographic Contest - Get your badge and win 1000 HIVE
Our Hive Power Delegations to the October PUM Winners
Feedback from the November 1st Hive Power Up Day - New Turnout Record