<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Om Vastre</title>
    <description>The latest articles on DEV Community by Om Vastre (@devom04).</description>
    <link>https://dev.to/devom04</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1811755%2F08024b59-427d-416c-8d4a-a28727429dcb.png</url>
      <title>DEV Community: Om Vastre</title>
      <link>https://dev.to/devom04</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devom04"/>
    <language>en</language>
    <item>
      <title>Send Email Programmatically in Flutter Using SMTP (Simplest Way)</title>
      <dc:creator>Om Vastre</dc:creator>
      <pubDate>Mon, 22 Jul 2024 14:13:48 +0000</pubDate>
      <link>https://dev.to/devom04/send-email-programmatically-in-flutter-using-smtp-simplest-way-25bf</link>
      <guid>https://dev.to/devom04/send-email-programmatically-in-flutter-using-smtp-simplest-way-25bf</guid>
      <description>&lt;p&gt;So many times we need to add email sending functionality to our flutter app, for that SMTP is first solution that comes in mind. There are various ways to send email programmatically but I'm sharing the simplest I found. I used it to send OTP to email for verification in flutter.&lt;br&gt;
We are going to use a library called &lt;a href="https://pub.dev/packages/mailer" rel="noopener noreferrer"&gt;'mailer'&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;So first of all we need a Gmail and App Password to send SMTP mail from respective mail. To create app password:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign in with gmail account from which you want to send mail.&lt;/li&gt;
&lt;li&gt;Then goto &lt;a href="https://myaccount.google.com/" rel="noopener noreferrer"&gt;Manage my google account&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Now you have to turn on 2 Step verification in order to create App Password&lt;/li&gt;
&lt;li&gt;For that go to &lt;code&gt;Security &amp;gt; How you sign in to Google &amp;gt; 2-Step Verification&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Enter your password, then mobile no and turn it on.&lt;/li&gt;
&lt;li&gt;Now search for 'App Password' in search bar, open it and create a new passkey of 16 character. Save it somewhere we require it further.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now open your flutter project and run following command to install mailer library: &lt;code&gt;flutter pub add mailer&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now add following function to your code to send mail:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';
import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server/gmail.dart';

sendEmail(BuildContext context) async {
  // TODO : Enter details below
  String name = ''; // your name
  String username = ''; // mail
  String password = ''; // 16 character long app password
  String receiverMail = ''; // receiver's mail
  String sub = ''; // subject of mail
  String text = ''; // text in mail

  final smtpServer = gmail(username, password);
  // SmtpServer class to configure an SMTP server: final smtpServer = SmtpServer('smtp.domain.com');

  final message = Message()
    ..from = Address(username, name)
    ..recipients.add(receiverMail)
    ..subject = sub
    ..text = text
  ..html = "&amp;lt;h4&amp;gt;Your message&amp;lt;/h4&amp;gt;&amp;lt;p&amp;gt; Your message&amp;lt;/p&amp;gt;"; // For Adding Html in email
  // ..attachments = [
  //   FileAttachment(File('image.png'))  //For Adding Attachments
  //     ..location = Location.inline
  //     ..cid = '&amp;lt;myimg@3.141&amp;gt;'
  // ];

  try {
    final sendReport = await send(message, smtpServer);
    print('Message sent: ' + sendReport.toString());
    ScaffoldMessenger.of(context)
        .showSnackBar(SnackBar(content: Text("Email Send Successfully")));
  } catch (e) {
    print('Message not sent.');
    print(e);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Complete TODO in above code and your function is ready to send mail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can add additional attachments &amp;amp; html to mail by using &lt;code&gt;..attachments&lt;/code&gt; &amp;amp; &lt;code&gt;..html&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Resources : &lt;a href="https://pub.dev/packages/mailer/install" rel="noopener noreferrer"&gt;Official Mailer Library&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>smtp</category>
      <category>dart</category>
      <category>help</category>
    </item>
    <item>
      <title>Firebase + Flutter Setup In Simplest Way (Windows)</title>
      <dc:creator>Om Vastre</dc:creator>
      <pubDate>Sat, 20 Jul 2024 20:17:02 +0000</pubDate>
      <link>https://dev.to/devom04/firebase-flutter-setup-in-simplest-way-windows-dp9</link>
      <guid>https://dev.to/devom04/firebase-flutter-setup-in-simplest-way-windows-dp9</guid>
      <description>&lt;p&gt;There are ways to add firebase to your project but the simplest way is to use FirebaseCLI, I tries with adding domain name to firebase apps then downloading json file and adding it in android app folder and adding library, but there is a catch when er try to add those libraries in that gradle.build files the gradle file structure and the structure shown in firebase add apps step don't match so beginner gets confused so simplest way to add firebase in flutter is to use Firebase CLI. Let's see how to do it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download Firebase CLI from here: &lt;a href="https://firebase.google.com/docs/cli#setup_update_cli" rel="noopener noreferrer"&gt;Download FirebaseCLI&lt;/a&gt;&lt;br&gt;
or direct link to start download : &lt;a href="https://firebase.tools/bin/win/instant/latest" rel="noopener noreferrer"&gt;Direct download&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then and run command &lt;code&gt;firebase login&lt;/code&gt; and login with required account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then need to install 'fireflutter' and add it to path, for that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run command : &lt;code&gt;dart pub global activate flutterfire_cli&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Then you will get to see a warning msg like : &lt;code&gt;"Warning: Pub installs executables into _C:\Users\PC\AppData\Local\Pub\Cache\bin_, which is not on your path. You can fix that by adding that directory to your system's "Path" environment variable. A web search for "configure windows path" will show you how."&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add path given in msg in Path variable in Environmental Variables. If you don't add to path you may face &lt;a href="https://stackoverflow.com/questions/70320263/error-the-term-flutterfire-is-not-recognized-as-the-name-of-a-cmdlet-functio" rel="noopener noreferrer"&gt;'flutterfire not recognized' error&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then close FirebaseCLI window and open your flutter project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now need to add required firebase libraries in flutter project for that open terminal and run command :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firebase Core Lib : &lt;code&gt;flutter pub add firebase_core&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Firebase Auth lib : &lt;code&gt;flutter pub add firebase_auth&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Firebase Realtime DB Lib : &lt;code&gt;flutter pub add firebase_database&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All other libraries are listed here : &lt;a href="https://firebase.flutter.dev/" rel="noopener noreferrer"&gt;Fireflutter Official Site&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then run command &lt;code&gt;flutterfire configure&lt;/code&gt; and choose project and apps you want to add to firebase project. After that this command will generate a file 'firebase_options.dart' which contains configuration and now go to firebase there you will get to see apps are added to firebase and setup is completed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Resources : &lt;a href="https://firebase.google.com/docs/flutter/setup?platform=android" rel="noopener noreferrer"&gt;Official Guide&lt;/a&gt;, &lt;a href="https://youtu.be/FkFvQ0SaT1I" rel="noopener noreferrer"&gt;Official Guide Video&lt;/a&gt;, &lt;a href="https://firebase.flutter.dev/" rel="noopener noreferrer"&gt;FireFlutter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>firebase</category>
      <category>dart</category>
    </item>
  </channel>
</rss>
