Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.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/7/css/36.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
带有CSS的CakePHP电子邮件_Php_Css_Email_Cakephp - Fatal编程技术网

带有CSS的CakePHP电子邮件

带有CSS的CakePHP电子邮件,php,css,email,cakephp,Php,Css,Email,Cakephp,我无法在电子邮件中获取css,以下是CakePHP电子邮件功能: function _sendMailUser($mailTo = array(), $mailFrom = array(), $repTo = array(), $mailSubject = null, $mailTemplate = null) { App::uses('CakeEmail', 'Network/Email'); $email = new CakeEmail(); $email ->

我无法在电子邮件中获取css,以下是CakePHP电子邮件功能:

function _sendMailUser($mailTo = array(), $mailFrom = array(), $repTo = array(), $mailSubject = null, $mailTemplate = null) {
    App::uses('CakeEmail', 'Network/Email');
    $email = new CakeEmail();
    $email -> from($mailFrom);
    $email -> bcc($mailTo);
    $email -> replyTo($repTo);
    $email -> subject($mailSubject);
    $email -> template($mailTemplate);
    $email -> emailFormat('html');

    return $email -> send();

}
电子邮件模板:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="<?php echo HTTP_ROOT; ?>css/style.css" type="text/css" />

</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">

    <center>
        <?php echo $this -> fetch('content'); ?>
    </center>

</body>

代码的兄弟

我的名字是约翰,我推荐使用

它是html和css分离文件的一个组件,将css插入样式应答器中,用于所有组成html的元素

警告,我在我的项目中使用,在使用多个htmls文件时经常出现问题


我为问题创建了一个修补程序,请与我联系以获取检索修补程序。

如果您使用css文件,它应该位于扩展名为style.css的
/app/webroot/css
中,然后您应该在模板文件中包含以下行:

<?php echo $this->Html->css(array('style')); ?>

对于视图文件:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <?php echo $this->Html->css(array('style')); ?>
    </head>
    <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">

        <center>
            <?php echo $this -> fetch('content'); ?>
        </center>

    </body>

您可以在模板中内联编写css:

 <h2 style="color:#818381">Here are the latest stories everyone's talking about...</h2>
以下是大家都在谈论的最新故事。。。

显示您的css代码。不要在电子邮件上链接css样式。你发过哪家电子邮件服务提供商的电子邮件?没有收到css,尝试了多家电子邮件提供商Gmail、Yahoo等。我使用内联样式和css转换为“内联css”,这是最好的css方法。例如,在实际将其传递给传输类之前,可以通过帮助器回调实现。您应该使用内联样式。不是每个邮件客户端都支持标题和/或正文中的样式标记。请在css文件中添加完整的URI:)“代码兄弟”-它看起来像一个节。我在哪里签字?也值得一读
 <h2 style="color:#818381">Here are the latest stories everyone's talking about...</h2>