问题描述
我正在尝试从我的 Flutter 应用程序发送电子邮件,但收到错误“证书尚未生效”。你能帮我理解问题出在哪里以及如何解决吗?我在 Google 帐户中启用了安全性较低的应用。
Future _mail() async {
String username = 'username @gmail.com';
String password = 'password';
final smtpServer = gmail(username,password);
final message = Message()
..from = Address(username)
..recipients.add('[email protected]')
..subject = 'Mail using mailer package :: ? :: ${DateTime.Now()}'
..text = 'This is the plain text.\nThis is line 2 of the text part.'
..html = "<h1>Write the content here</h1>\n<p>hey! its easy use html tags for alignments</p>";
try {
final sendReport = await send(message,smtpServer);
print('Message sent: ' + sendReport.toString());
} on MailerException catch (e) {
print('Message not sent.');
for (var p in e.problems) {
print('Problem: ${p.code}: ${p.msg}');
}
}
}
错误:
E/Flutter (29811): [ERROR:Flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error:
E/Flutter (29811): CERTIFICATE_VERIFY_Failed: certificate is not yet valid(handshake.cc:354))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)