我想向用户发送邮件,邮件正在发送,但其中的链接现在显示为链接,我还想在邮件中嵌入徽标但徽标未显示,下面是我的代码。我正在使用蛋糕2.8
$Email = new CakeEmail();
$Email->from(array('admin@wacscoac.org'=>'West Africal College of Surgeons'));
$Email->to($email);
$Email->subject('Reviewer Invitation From West African College of Surgeons');
$Email->send('Dear Reviewer, You have been invited by the Head of Faculty of $faculty from the West'
. 'African College of Surgeons to register as a reviewer. Please click on the link '
. 'below to register'
. 'http://wacscoac.org/edms/users/addreviewer');
$Email->attachments('img/logo.png');
答案 0 :(得分:3)
假设您希望徽标也是链接:
我认为最好的方法是使用模板,以便在.ctp文件中使用Html助手
$Email->attachments(['img/logo.png'=> [
'file' => 'img/logo.png',
'mimetype' => 'image/png',
'contentId' => 'logo'
]]);
$Email->template('test');
$Email->emailFormat('html');
$Email->viewVars(array(
'faculty' => "Faculty",
));
$Email->send();
如果您希望附件内联,则指定contentId
非常有用,如手册中所述here
之后,您必须在\src\Template\Email\html\test.ctp
<p>Dear Reviewer,</p>
<p>You have been invited by the Head of Faculty of <?= $faculty ?>
from the West African College of Surgeons to register as a reviewer.</p>
<p>Please click on the link below to register</p>
<?= $this->Html->link(
'<img src="cid:logo" alt="">',
'http://wacscoac.org/edms/users/addreviewer',
['escape' => false]);
?>
答案 1 :(得分:0)
我个人认为我会使用HTML标签
<a href = "site you desire">Link tage</a>
但请记住,您需要设置
$headers .= "Content-type: text/html\r\n";
电子邮件,祝你好运。
答案 2 :(得分:0)
$link = '<a href="http://wacscoac.org/edms/users/addreviewer"'>
<img src="img/logo.png" alt="">
</a>';
然后
$Email->send('Dear Reviewer, You have been invited by the Head of aculty of $faculty from the West'
. 'African College of Surgeons to register as a reviewer. Please click on the link '
. 'below to register'
. $link);