发送邮件后的消息mailer:flutter

问题描述

我正在尝试通过弹出消息甚至警报对话框来通知消息是否已发送。

目前我只有一个显示但在控制台中的打印......所以对用户没有用。

我如何达到我的目标?

  sendMail() async {
    // Information connexion serveur smtp
    String username = 'xxx';
    String password = 'xxxx';
    String domainSmtp = 'xxx';

    final smtpServer = SmtpServer(domainSmtp,username: username,password: password,port: 587);

    //Création du message
    final message = Message()
      ..from = Address(username,'')
      ..recipients.add('xxxx')

      //..ccRecipients.addAll(['[email protected]','[email protected]'])
      //..bccRecipients.add(Address('[email protected]'))
      ..subject =
          "Demande :: ? :: ${DateTime.now()}"
      ..text = ''
      ..html =
          "<h1>Nom: ${nomController.text} <p></p> Prénom: ${prenomController.text} <p></p> Email: ${emailController.text}</h1> <img src=\"data:images/Logo_fini2.1.png>  \n<p></p>";

    try {
      final sendReport2 = await send(message,smtpServer);
      var connection = PersistentConnection(smtpServer);
      await connection.send(message);
      await connection.close();
      print('Message envoyé: ' + sendReport2.toString());
    } on MailerException catch (e) {
      print('cMessage envoyé.');
      for (var p in e.problems) {
        print('Probleme: ${p.code}: ${p.msg}');
      }
    }
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)