Html 如何使用颤振邮件包发送复杂的电子邮件

Html 如何使用颤振邮件包发送复杂的电子邮件,html,email,dart,flutter,mailer,Html,Email,Dart,Flutter,Mailer,我可以用Mailer软件包()发送简单的HTML电子邮件。在他们的示例中,“Test\n嘿!这里有一些HTML内容”“作为一个简单的HTML文本工作: final message = new Message() ..from = new Address(username, 'Your name') ..recipients.add('destination@example.com') ..ccRecipients.addAll(['destCc1@example.com', 'destCc2@e

我可以用Mailer软件包()发送简单的HTML电子邮件。在他们的示例中,
“Test\n嘿!这里有一些HTML内容”

作为一个简单的HTML文本工作:

final message = new Message()
..from = new Address(username, 'Your name')
..recipients.add('destination@example.com')
..ccRecipients.addAll(['destCc1@example.com', 'destCc2@example.com'])
..bccRecipients.add(new Address('bccAddress@example.com'))
..subject = 'Test Dart Mailer library :: There are 2 aspects to this question.

  • How to set the stripo html.
  • How to adapt an html template. (Modify the content to change parts of the template)
To set the template simply do:

message.html =
'''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[... copy the complete template here ...]
</html>'''
final message=新消息()
…发件人=新地址(用户名“您的姓名”)
..收件人。添加('destination@example.com')
…ccRecipients.addAll(['destCc1@example.com', 'destCc2@example.com'])
..b委托人。添加(新地址('bccAddress@example.com'))

…主题='测试Dart邮件程序库::这个问题有两个方面

  • 如何设置StripoHTML
  • 如何调整html模板。(修改内容以更改模板的各个部分)
要设置模板,只需执行以下操作:

var nameFromSomeInput = 'Jane Doe';
var yourHtmlTemplate = '<html>Dear {{NAME}}</html>';
message.html = yourHtmlTemplate.replaceAll('{{NAME}}', nameFromSomeInput);

“如何将此HTML代码作为新Message()方法的..HTML参数的字符串传递?”->我不太明白您的意思。是否询问如何读取Dart中的文件?“…html”Message()函数的参数将字符串作为输入。因此,我想知道如何将HTML文件转换为字符串并将其传递到“.HTML”中。您首先需要使用Dart内置实用程序打开文件并将其读取为字符串。详情见: