【问题标题】:wp_mail use WordPress's default email template for sending emailwp_mail 使用 WordPress 的默认电子邮件模板发送电子邮件
【发布时间】:2019-03-19 07:34:36
【问题描述】:

有什么方法可以使用 WordPress 用于发送电子邮件的默认模板(在注册、密码重置等方面)从 WordPress 发送电子邮件。

我正在使用wp_mail 函数发送电子邮件,但是如何在消息中包含自定义内容的模板。

谢谢

【问题讨论】:

  • 您要使用自定义模板吗?
  • 是的,但不是自定义的,WordPress 使用的带有蓝色背景标题的标题。

标签: php wordpress email


【解决方案1】:

尝试使用本教程:https://www.wpbeginner.com/plugins/how-to-change-sender-name-in-outgoing-wordpress-email/


您需要在主题的 functions.php 文件或特定于站点的插件中添加以下代码。

// Function to change email address

function wpb_sender_email( $original_email_address ) {
    return 'tim.smith@example.com';
}

// Function to change sender name
function wpb_sender_name( $original_email_from ) {
    return 'Tim Smith';
}

// Hooking up our functions to WordPress filters 
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );
This code simply replaces the default WordPress sender name and email address with your custom sender name and email address.

【讨论】:

  • 我认为这完全忽略了这个问题。 OP 没有问如何更改发件人的姓名,他是在问如何使 wp_mail 功能使用 wrpdress 电子邮件模板。
猜你喜欢
  • 1970-01-01
  • 2012-05-17
  • 2021-03-15
  • 2018-10-19
  • 1970-01-01
  • 2010-10-23
  • 2016-09-20
  • 2021-08-09
  • 2020-09-11
相关资源
最近更新 更多