Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 发送<;a>;使用Swift Mailer在电子邮件正文中标记_Php_Email_Swiftmailer - Fatal编程技术网

Php 发送<;a>;使用Swift Mailer在电子邮件正文中标记

Php 发送<;a>;使用Swift Mailer在电子邮件正文中标记,php,email,swiftmailer,Php,Email,Swiftmailer,我是Swift Mailer的新手,希望在链接回我主页的HTML消息正文中包含一个链接。但是,当我在消息中包含锚定标记时,PHP脚本不会运行(当我包含其他元素(例如标题标记)时,脚本会起作用。不确定我可能会缺少什么 PHP: 出现语法错误。只需删除href中的单引号即可: $message->setBody( '<html>' . ' <head></head>' . ' <body>' . ' This is

我是Swift Mailer的新手,希望在链接回我主页的HTML消息正文中包含一个链接。但是,当我在消息中包含锚定标记时,PHP脚本不会运行(当我包含其他元素(例如标题标记)时,脚本会起作用。不确定我可能会缺少什么

PHP:


出现语法错误。只需删除
href
中的单引号即可:

$message->setBody(
    '<html>' .
    ' <head></head>' .
    ' <body>' .
    ' This is my message' .
    '<a href="http://www.mazihealth.com">Sign in</a>'.
    ' </body>' .
    '</html>',
    'text/html' // Mark the content-type as HTML
);
$message->setBody(
'' .
' ' .
' ' .
“这是我的留言”。
''.
' ' .
'',
'text/html'//将内容类型标记为html
);
此外,您可能会发现使用语句来概括内容更容易。这使读取/编辑大型字符串更容易。以下是一个示例:

$body = <<<EOD
<html>
    <head></head>
    <body>
        This is my message .
        <a href="http://www.mazihealth.com">Sign in</a>
    </body>
</html>
EOD;

$message->setBody(
    $body,
    'text/html' // Mark the content-type as HTML
);

$body=就是这样。有趣的是,要嵌入图像,我需要在图像src周围加上单引号。我想这让我很反感。谢谢你对herdoc语句的建议。
$body = <<<EOD
<html>
    <head></head>
    <body>
        This is my message .
        <a href="http://www.mazihealth.com">Sign in</a>
    </body>
</html>
EOD;

$message->setBody(
    $body,
    'text/html' // Mark the content-type as HTML
);