Flutter 使用颤振邮件包发送电子邮件

Flutter 使用颤振邮件包发送电子邮件,flutter,Flutter,如何在不启用google security中的“不太安全的应用程序访问”的情况下使用Flatter mailer软件包发送电子邮件。我想要类似的东西,比如用NodeJS发送邮件。任何人都可以发送代码片段来更好地理解吗 我试过这个 sendMail async() { String username = 'example@gmail.com'; String password = 'password'; // Don't want to write my password in

如何在不启用google security中的“不太安全的应用程序访问”的情况下使用Flatter mailer软件包发送电子邮件。我想要类似的东西,比如用NodeJS发送邮件。任何人都可以发送代码片段来更好地理解吗

我试过这个

sendMail async() {
     String username = 'example@gmail.com';
     String password = 'password'; // Don't want to write my password in code

// Creating the Gmail server
     final smtpServer = gmail(username, password);

     final message = Message()
       ..from = Address(username)
       ..recipients.add('recipient@gmail.com')      //recipient email
       ..subject = 'Subject line'                   //subject of the email
      ..text = 'This is the plain text.\nThis is line 2 of the text part.';

     try {
       final sendReport = await send(message, smtpServer);
       print('Message sent: ' +
           sendReport.toString());
     } on MailerException catch (e) {
       print('Message not sent. \n' +
           e.toString());
     }

如果有一种只发送邮件而不提及密码的方法,我很乐意知道。

是的,我使用了相同的参考,但我正在寻找一种方法,在代码本身中不写入密码。我想让它只使用电子邮件发送邮件,或者像我们在Node.js/FlaskYes中所做的那样自动进行身份验证。我使用了相同的引用,但我正在寻找一种方法,在代码本身中不写入密码。我希望它可以只使用电子邮件发送邮件,也可以像Node.js/Flask中那样自动进行身份验证