我正在使用mailer包发送主机为QQ
的邮件,该邮件在中国非常流行。
String username = 'xx@qq.com';
String password = 'xx';
final smtpServer = new SmtpServer("smtp.qq.com", port: 465, username: username, password: password);
// Create our message.
final message = new Message()
..from = new Address(username, 'Your name')
..recipients.add('receiver@qq.com')
..subject = 'Test Dart Mailer library :: :: ${new DateTime.now()}'
..text = 'This is the plain text.\nThis is line 2 of the text part.'
..html = "<h1>Test</h1>\n<p>Hey! Here's some HTML content</p>";
final sendReports = await send(message, smtpServer);
但是它失败了。我还有什么吗?
答案 0 :(得分:1)
qq smtp服务器需要ssl标志:
String username = 'xx@qq.com';
String password = 'xx';
final smtpServer = new SmtpServer("smtp.qq.com", ssl: true, port: 465, username: username, password: password);
(请注意ssl: true
参数)。
此外,版本2.2.0现在具有qq(username, password)
SMTP服务器定义功能(类似于gmail
功能)。