title: How to send mail with attachments in Flutter?
body: <p>I found dart plugin called mailer3: "^1.1.9". Previously I create an image in mobile temp directory. In Flutter mobile app I try to send this saved picture using mailer3 plugin as a mail. The mail reach the destination, I don't get error but seems lost the attachment in process.</p>
  
  <p>In dart it works very well and send the attachment as well. In flutter I can use the temp directory to show the image in app but cannot be able attache to mail. </p>
  
  <p>The image location is in the temp folder of the device: </p>
  
  <ul>
  <li>'/data/user/0/com.myApp.myApp/app_flutter/20180700087.jpg'</li>
  </ul>
  
  <p>I can show the image using below code:</p>
  
  <ul>
  <li>new FileImage(File('$newDekontImage'),</li>
  </ul>
  
  <p><strong>Error:</strong> </p>
  
  <pre><code>E/flutter (21184): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
  E/flutter (21184): FileSystemException: Cannot open file, path = '/data/user/0/com.myApp.myApp/app_flutter/20180700087.jpg' (OS Error: No such file or directory, errno = 2)
  </code></pre>
  
  <p>How to send mail with attachments in Flutter with provided information in this question?</p>
  
  <p><strong>The Flutter Code:</strong></p>
  
  <pre><code>// TODO: SEND MAIL
  void _sendMail() async {
    if (!_formKey.currentState.validate()) {
      return;
    } else {
      _formKey.currentState.save();
  
      var _options = new GmailSmtpOptions()
      ..username = “mymailaddress@gmail.com"
      ..password = “myPassword”;
  
      var _emailTransport = new SmtpTransport(_options);
      var _envelope = new Envelope()
      ..from = "mymailaddress@gmail.com"
      ..recipients.add(_receiverMailAddress)
        ..subject = "${_userDekontDetails[0][0].toString()} - Receipt”
        ..attachments.add(await new Attachment(file: await new File('$newDekontImage')))
        ..text = "${_userDekontDetails[0][0].toString()} - Receipt"
        ..html = '&lt;h3&gt;${_userDekontDetails[0][0].toString()} Receipt.&lt;/h3&gt;'
            '&lt;p&gt;Hi, registered under my name, I am sending the receipt (${widget._currentUserReceiptNo}) with attached to this mail.&lt;/p&gt;'
            '&lt;p&gt;&lt;/p&gt;'
            '&lt;h5&gt;Regards, &lt;/br&gt;&lt;/h5&gt;'
            '${_userDekontDetails[0][0].toString()}';
  
      _emailTransport.send(_envelope)
        ..then((envelope) =&gt; print('Email sent'))
        ..catchError((e) =&gt; print('Error occured: $e'));
    }
  }
  </code></pre>