【问题标题】:how to get path of html file in php email如何在php电子邮件中获取html文件的路径
【发布时间】:2020-06-04 10:02:05
【问题描述】:

我想为电子邮件的内容添加文件路径。 我创建了一个 html 电子邮件模板文件。 我已经尝试了以下代码,但它不起作用。

$content ="".file_get_contents(basename(__DIR__).'/welcome-email-template.html');

wp_mail($to, $subject, $content);

【问题讨论】:

  • 1.你在用wordpress吗? 2. 您是否尝试过在浏览器中打开模板文件?在发送邮件之前将其与 basename(DIR).'/welcome-email-template.html' 的回显相匹配。简而言之,您可能没有找到正确的路径。
  • 那么您的 http 服务器的错误日志文件说明了什么问题?
  • 是的,我正在使用 wordpress。我在浏览器中打开了文件,它正在工作。我在函数文件的同一目录中有模板文件。
  • 我是远程而不是本地执行项目
  • 认为您需要检查并编辑您的问题stackoverflow.com/help/how-to-ask

标签: php wordpress email


【解决方案1】:

我将 basename(DIR) 更改为 TEMPLATEPATH

$content ="".file_get_contents(TEMPLATEPATH.'/welcome-email-template.html'); wp_mail($to, $subject, $content);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 2013-02-19
    • 2022-08-24
    • 2021-08-27
    • 2011-08-23
    • 1970-01-01
    相关资源
    最近更新 更多