如何更改 WordPress 默认发件人及邮箱地址

  • 时间:2020-05-16 19:39:54
  • 分类:网络文摘
  • 阅读:142 次

当用户注册或需要找回密码时,wordpress 会自动将注册的用户名、随机密码和登录地址发到用户的注册邮箱中。默认通过 mail() 函数发送邮件的发件人是:wordpress<wordpress@uuxn.com>,且无法通过后台更改。不过我们可以使用简单的一段代码,通过 wp_mail_from 和 wp_mail_from_name 函数来自定义 WordPress 默认发件人及邮箱地址。方法如下:

添加如下代码到当前 wordpress主题的函数模板文件 functions.php 最后一个 ?> 的前面:

  1. //change WordPress default mail_from information
  2. add_filter('wp_mail_from', 'new_mail_from');
  3. add_filter('wp_mail_from_name', 'new_mail_from_name');
  4. function new_mail_from($old) {
  5.  return '邮箱地址';
  6. }
  7. function new_mail_from_name($old) {
  8.  return '发件人姓名';
  9. }

然后修改代码中的邮箱地址和发件人姓名,保存文件即可。

推荐阅读:
Funny YouTuber Creates Device to Shoot Facemasks To Your Face  YouTube’s New “Viewer Applause” Feature Provides Revenue for Blo  Taiwanese Instagram Grandparents Prove Blogging and Social Media  These Incredible Hologram Machines Could Change the Vlogging Gam  Prepare All Keyboard Warriors: A TikTok and Twitter Merger is Ab  Content Creation Platforms That Pay in Crypto  How to be like Elon Musk: An Influencer CEO  Your Simple Guide to Ultimate Technology Stack Every Blogger Nee  Recursive Algorithm to Encrypte a String  Reconnect the Nodes in Linked List by Odd/Even in Place (Odd Eve 
评论列表
添加评论