Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

dart - Message after sending email (mailer: flutter)

I'm trying to put a pop or even an alertedialog to announce that the message is sent or not.

Currently I only have a print that displays but in the console .. So not useful for the user.

How do I get to my goal?

  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>  
<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}');
      }
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use a snackbar or a AlertDialog

More info on snackbar :https://flutter.dev/docs/cookbook/design/snackbars


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...