我一直在阅读催化剂框架,我试图发送一封带有HTML内容的电子邮件,但没有成功。
我试着使用催化剂::Plugin::Email,就像这里一样。电子邮件被发送,但所有内容都以纯文本显示。
sub send_email : Local {
my ($self, $c) = @_;
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
body => $c->view('Web')->render($c, 'email.tt', {
additional_template_paths => [ $c->config->{root} . '/email_templates'],
email_tmpl_param1 => 'foo'
}
),
);
# Redirect or display a message
}
我也读过关于催化剂::视图::电子邮件::模板的文章,但我不会安装它。
有什么想法吗?
发布于 2013-09-05 20:04:11
我现在可以用催化剂::Plugin::Email发送HTML电子邮件。来自文件:
"email()接受与Email::MIME::create()相同的参数。“
查看电子邮件::MIME::Creator,create方法结构是:
my $single = Email::MIME->create(
header_str => [ ... ],
body_str => '...',
attributes => { ... },
);
my $multi = Email::MIME->create(
header_str => [ ... ],
parts => [ ... ],
attributes => { ... },
);
返回属性。散列键直接对应于方法或修改电子邮件中的消息::MIME::修饰符。允许的键是: content_type、字符集、名称、格式、边界、编码、处理和文件名。它们将映射到"$attr_set“以进行消息修改。
这是它正在工作的代码:
sub send_email : Local {
my ($self, $c) = @_;
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
body => $c->view('Web')->render($c, 'email.tt', {
additional_template_paths => [ $c->config->{root} . '/email_templates'],
email_tmpl_param1 => 'foo'
}
),
attributes => {
content_type => 'text/html',
charset => 'utf-8'
},
);
# Redirect or display a message
}
https://stackoverflow.com/questions/18624811
复制相似问题