0

我在这里有一些代码,我试图用 css 为 $first 的 PHP 变量设置样式,但显然有些不对,因此我在这里的原因。

我最终想为整条消息设置样式并包含徽标和/或背景颜色,以便发送此电子邮件时是“html电子邮件”,但我对PHP一无所知,我想我正在一点一点地学习.

这是我的代码:-------->

$user = "$email";
$usersubject = "Thank you for subscribing";
$userheaders = "From: subscriptions@3elementsreview.com\n";
$userheaders .= "Content-type: text/html\r\n";
$usermessage = "Welcome <span style='color:#ff6000; font-size:1.25em; font-    weight:bold;>$first</span>,

We're glad you've decided to subscribe to our email list!

There's a lot of great things happening at 3Elements that we can't wait to show you.

So stay tuned for notifications about submission periods, issue release dates, contests, and other news. Also, be sure to like us on Facebook and follow us on Twitter!

Sincerely,

The 3Elements Team


www.3ElementsReview.com
Facebook.com/3elementsreview
@3ElementsReview";

mail($user,$usersubject,$usermessage,$userheaders);
4

3 回答 3

0

尝试为您的 HTML 属性使用双引号并连接您的 $first 变量,如下所示:

$user = "$email";
$usersubject = "Thank you for subscribing";
$userheaders = "From: subscriptions@3elementsreview.com\n";
$userheaders .= "Content-type: text/html\r\n";
$usermessage = "Welcome <span style=\"color:#ff6000; font-size:1.25em; font-weight:bold;\">".$first."</span>,

We're glad you've decided to subscribe to our email list!

There's a lot of great things happening at 3Elements that we can't wait to show you.

So stay tuned for notifications about submission periods, issue release dates, contests, and other news. Also, be sure to like us on Facebook and follow us on Twitter!

Sincerely,

The 3Elements Team


www.3ElementsReview.com
Facebook.com/3elementsreview
@3ElementsReview";

mail($user,$usersubject,$usermessage,$userheaders);
于 2013-08-20T01:40:16.407 回答
0

我可能会从改变开始

<span style='color:#ff6000; font-size:1.25em; font-    weight:bold;>

<span style='color:#ff6000; font-size:1.25em; font-weight:bold;'>

我还建议将HEREDOC用于大块文本,例如

$usermessage <<<EOD

Welcome <span style="color:#ff6000; font-size:1.25em; font-weight:bold;">$first</span>,

We're glad you've decided to subscribe to our email list!

There's a lot of great things happening at 3Elements that we can't wait to show you.

So stay tuned for notifications about submission periods, issue release dates, contests, and other news. Also, be sure to like us on Facebook and follow us on Twitter!

Sincerely,

The 3Elements Team


www.3ElementsReview.com
Facebook.com/3elementsreview
@3ElementsReview
EOD;
于 2013-08-20T01:41:14.023 回答
0

您可能缺少 html 或 body 标签?我发布了我目前正在工作的版本。您可以在此基础上进行修改。请注意,gmail、yahoo 等不同的邮件服务器会检测到不同的代码格式。某处有一个很好的比较

  $mail_body = '
    <html>
    <body>
    <p><img style="vertical-align: top;" src="http://www.chenlikonlinestore.com/css/images/logo.png" alt="logo" width="238" height="41" /></p>
    <p><a class="right" title="ChenLikPharmacy Sdn Bhd" href="http://www.facebook.com/ChenLikPharmacy" target="_blank"><img src="http://ctrlq.org/html-mail/img/facebook.png" alt="Facebook" width="25" height="25" /></a></p>
    <h3>Newsletter</h3>
    <p>Hello ' . $name . ',</p>
    <p><a href="http://www.chenlikonlinestore.com/promotions.php">Click here and check out our latest promotion!</a></p>
    <p>~Philip @ ChenLik Pharmacy Sdn. Bhd.</p>
    <hr />
    <p>This is computer generated newsletter, please do not reply to this email. <a href="http://www.chenlikonlinestore.com/php_codes/optout.php?e='.$email.'">Click here</a> to unsubscribe</p>
    </body>
    </html>';
于 2013-08-20T01:42:29.007 回答