在php电子邮件正文中打印链接

时间:2016-05-31 05:26:28

标签: php

我想在php电子邮件正文中打印'click here'作为链接。按照我使用的代码。

$mail->Subject = "New leave request";
$mail->Body = "You have a leave request from $emp_name on $today. To conform this leave"?><?php echo'<a href="http://localhost:127/lms/index.php">Click Here</a>';
$mail_to = $email;

即使我从所有可能的方式检查它,仍然无法做到这一点。请帮忙!

3 个答案:

答案 0 :(得分:2)

你可以简单地使用它:

$mail->MsgHTML("<b>Hi, your first SMTP mail has been received.<a href='http://localhost:127/lms/index.php'>Click Here</a>");

答案 1 :(得分:0)

将电子邮件格式设置为HTML

$message = "<a href="http://localhost:127/lms/index.php">Click Here</a>";
$mail->IsHTML(true);// Set HTML TRUE
$mail->Body = $message;

答案 2 :(得分:0)

//使用html body

 $mail->Body = "<p>This is the HTML message body <b><a href='{$link_address}'> Link </a></b></p>";

//没有html正文

$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
$mail->Subject = "New leave request";
$mail->Body = "You have a leave request from {$emp_name} on {$today}. To conform this leave Click Here";
$mail_to = $email;

我希望它会有所帮助