以下代码效果很好。它允许用户向其他人发送电子邮件以推荐我的网站。
如何用$ _POST ['sendername']替换下面的“Michael”?我试过了,但没用。
提前致谢,
约翰
$msg = "<html><body>Hello, your friend Michael recommends that you use <a href='http://www.site.com/'>site.com</a> Please visit the site.<br><br><img src='http://site.com/images/blacklogo.PNG'></body></html>";
$subject = "Try out Site.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $_POST['sendername'] . "\r\n";
foreach($_POST['email'] as $email){
mail($email, $subject,$msg,$headers);
}
答案 0 :(得分:3)
简单地:
$msg = "<html><body> … ".htmlspecialchars($_POST['sendername'])." … </body></html>";