【问题标题】:Insert HTML Email Template in PHP在 PHP 中插入 HTML 电子邮件模板
【发布时间】:2012-10-11 23:30:57
【问题描述】:

有人可以帮助我了解问题所在。我已经尝试过几次让它正常运行,但没有成功。我正在尝试将我的 HTML 电子邮件模板插入到 php 文件中,该文件会生成自动电子邮件响应以注册到我的站点。

这是文件:

function simplr_send_notifications($atts, $data, $passw) {
$site = get_option('siteurl');
$name = get_option('blogname');
$user_name = @$data['username'];
$email = @$data['email'];
$notify = @$atts['notify'];
$emessage = apply_filters('simplr_email_confirmation_message');
$message = <<<EOF 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

   I cut out the bulk of the template to save space...
        </table>
    </center>
</body>
</html>
EOF;
$headers = "From: $name" . ' <' .get_option('admin_email') .'> ' ."\r\n\\";
wp_mail($notify, "A new user registered for $name", "A new user has registered for $name.\rUsername: $user_name\r Email: $email \r",$headers);
$emessage = $emessage . "\r\r---\r";
    if(!isset($data['password'])) {
        $emessage .= "You should login and change your password as soon as possible.\r\r";
    }
$emessage .= "Username: $user_name\r";
$emessage .= (isset($data['fbuser_id']))?'Registered with Facebook':"Password: $passw\rLogin: $site/wp-login.php";
wp_mail($data['email'],"$name - Registration Confirmation", $emessage, $headers);

感谢任何帮助!谢谢。

【问题讨论】:

  • 错误信息是什么?语法?
  • 如果您提供有关什么不起作用、发生了什么以及您收到的任何错误消息的上下文,这将很有帮助。
  • 根据我的阅读,您永远不会关闭调用 apply_filters()__(" 语句。你有没有错过那行的结尾?
  • 我在行出现错误:$message =
  • 好吧,你必须停止使用@,你隐藏了所有错误。

标签: php html email templates


【解决方案1】:

试试这个

<?php



            $template_text=addslashes('<table background="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.gif;"><tr><tr><th background="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.gif">mail</th></tr><tr><tr><th>email</th></tr> <tr><tr><th>gmail</th></tr><tr><td><img src="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.jpg" alt="baba"" /></td> </tr></table>');

            eval("\$body=\"$template_text\";");

            $header="Content-type:text/html \r\n";
            $header.="From: From Name <noreply@yourweb.com> \r\n";

            mail("yiy143@gmail.com","Activate Your Account",$body,$header);
?>

【讨论】:

  • 除非绝对必要,否则不要使用 eval 你不会相信让它成为非 bug 有多么困难(@ 987654321@).
猜你喜欢
  • 2010-12-16
  • 2023-02-23
  • 1970-01-01
  • 1970-01-01
  • 2017-08-31
  • 1970-01-01
  • 2011-04-15
  • 1970-01-01
  • 2011-03-15
相关资源
最近更新 更多