mime - 语法错误,意外的 T_SL

标签 mime php

我是 php 的新手,我正在使用一个脚本来创建一个名为“mime_mailer”的函数,它基本上允许我使用 PHP 发送可以用 CSS 设计的电子邮件,而不仅仅是纯文本.

然而,在我的注册脚本中,我尝试编写一些发送 CSS 电子邮件的代码,但我收到一条错误消息,指出存在语法错误。有人可以告诉我这个吗?

            $subject = "Your Red-line Account";
    $css     = "body{ color: #090127; background-color: #f0f0f0; }"; 
    $to     =   $usercheck;

    //Message
    $message =<<<END 
                <html>
                    <head>
                        <title>
                            Red-line
                        </title>
                    </head>
                    <body>
                        <p>
                            Hi $first_name, 
                        </p> 

                        <p>
                            Your Red-line account is almost complete. To finish, go to <a href='www.thered-line.com'>The Red-line</a> and enter your eight digit confirmation code.
                        </p> 

                        <p>
                            Your confirmation code is: <b>$code</b>
                        </p> 

                        <p>
                            Sincerely,
                        </p> <br />

                        <p>
                            The Red-line Operator
                        </p> 
                    </body>
                </html>
            END;

                    //  To send HTML mail, the Content-type header must be set
        $headers    =   'MIME-Version: 1.0' . "\r\n";
        $headers    .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

                    //  Additional headers
        $headers    .=  "From: The Red-line <messages@theredline.com>\r\n";
        $headers    .=  "To: $first_name $last_name <$usercheck>\r\n";

                    //  Mail it
        require_once("function_mime_mailer.php");


        mime_mailer($to, $subject, $message, $headers, NULL, $css); 
}

这里是“function_mime_mailer.php”文件的代码。

  if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])) send_404(); // stop http access           to         this file

 function mime_mailer($to, $subject, $message, $headers = NULL, $attachments = NULL, $css = NULL)
 {
       if(!preg_match('/^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-        z]{2,6})$/', $to)) return FALSE;
if(preg_match('/<(html|head|body|div|a|h|p|table|br|img|b|hr|ol|ul|span|pre|i|form)[^>]*[^>]*>/i', $message)) $html = TRUE;

 if(stristr($message, '<body')) $message = stristr($message, '<body');
     $message = delete_local_links($message);
 if(empty($headers)){
     $headers = "MIME-Version: 1.0\n";
 }else{
     $headers.= "\nMIME-Version: 1.0\n";
 }
 if(empty($html)){
     $result = plain_text($message);
 }elseif(isset($html) and $html == TRUE){
     if(!isset($css)) $css = NULL;
     if(preg_match('/<img[^>]+>/i', $message)){
       $result = multipart_related($message, $css);
   }else{
       $result = multipart_alternative($message, $css);
   }
 }
 $result['message'] = delete_non_cid_images($result['message']);
 if(!empty($attachments)){
   $parts = attachments($attachments);
   array_unshift($parts, implode('', $result));
   $result = multipart_mixed($parts);
 }
$headers = $headers.$result['headers'];
//print '<pre>'.htmlspecialchars($headers.$result['message']).'</pre>';exit;
if(mail($to, $subject, $result['message'], $headers)) return TRUE;
return FALSE;
}
?> 

最佳答案

刚遇到同样的问题。

原来是和我开场HERDEOC在同一行的内容

错误的例子

echo <<<HEREDOC code started on this line
HEREDOC;

正确的例子

echo <<<HEREDOC
code should have started on this line
HEREDOC;

希望这对其他人有帮助!

关于mime - 语法错误,意外的 T_SL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5416437/

相关文章:

python - Django 管理员突然仅在生产环境中注销(拒绝执行脚本,因为其 MIME 类型 ('text/html' )不可执行)

php - 如何在控制台上获取 php 文档?

javascript - 如何根据邮政编码限制用户在 Virtuemart 中注册

PHP如何循环遍历post数组

php - 如何在 smarty codeigniter 中获取基本 url

iis-7 - 为什么 IIS 要求声明 mime 类型?

php - MIME 类型检查对文件上传没用? (特别是使用 Javascript 文件 API)?

java - 如何显示来自 HTTP Web 服务器的图像?

php - 在匹配使用变量 : PHP:preg_match 形成的模式时转义字符的特殊含义

email - MIME 消息中的电子邮件地址是否有标准格式?