如何在不启用Google安全性中启用“安全性较低的应用访问权限”的情况下,使用Flutter邮件程序包发送电子邮件。我想要类似的东西,例如在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());
}
如果有一种方法可以发送邮件,不提及密码,我将很高兴知道它。