最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp mail - Using wp_mail() function outside of WordPress and through PHP CLI

programmeradmin2浏览0评论

I am developing a simple PHP script that will send emails to users. The script is located outside of WP directory and its run through a cronjob. Example cron job call:

php /PATH/TO/SCIRPT/script.php >> /PATH/TO/SCIRPT/history.log

and here’s part of the code:

<?php

require_once "/PATH/TO/WP/wp-load.php";

$res = wp_mail('email', 'title', 'body');

When I use PHP CLI to run the script $res is always false. But if I run the same script from the web it works just fine.

Below are the server details: ubuntu 16.04lts up-to-date with php 7.0.28-0ubuntu0.16.04.1 (cli) ( NTS )

Any help will be much appreciated.

发布评论

评论列表(0)

  1. 暂无评论