email - Mail through Cron Execution does not work!

I have been trying to execute the PHP mail() function and wp_mail() function in a PHP function in WordPress.The PHP func

I have been trying to execute the PHP mail() function and wp_mail() function in a PHP function in WordPress.

The PHP function is called by a cron hook. The problem is, it doesn't execute the mail() or wp_mail() functions at all. I even threw it inside another function which I know works perfectly, and again, the cron doesn't execute the mail command. It works outside the function and it works if I call the function manually (myfunction();) but when cron calls it, it doesn't work.

Any light? WP 2.9

I have been trying to execute the PHP mail() function and wp_mail() function in a PHP function in WordPress.

The PHP function is called by a cron hook. The problem is, it doesn't execute the mail() or wp_mail() functions at all. I even threw it inside another function which I know works perfectly, and again, the cron doesn't execute the mail command. It works outside the function and it works if I call the function manually (myfunction();) but when cron calls it, it doesn't work.

Any light? WP 2.9

Share Improve this question edited Mar 28, 2019 at 12:54 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Dec 22, 2010 at 18:55 user2121user2121
Add a comment  | 

2 Answers 2

Reset to default 1

I'd say the first thing to check is whether or not the cron is actually running properly. Whenever I have issues like this, it's usually with the cron run itself, not with the code it's calling.

Remove all of the code inside your hooked function and replace it with a single line that sets an option--something named "my_cron_last_ran" or whatever--and set the option's value to the current time. If the option doesn't appear in your wp_options table, the cron hasn't run properly.

The other troubleshooting thing I'd try is to remove everything but the mail stuff from your hooked function. If it runs and sends mail, then the issue could be that code BEFORE your mail stuff is erroring out and causing the whole thing to fail.

Based on what you wrote, wp_mail works but cron doesn't. So that's where you start troubleshooting: Find out why your function isn't triggering via cron.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745650051a4638208.html

相关推荐

  • email - Mail through Cron Execution does not work!

    I have been trying to execute the PHP mail() function and wp_mail() function in a PHP function in WordPress.The PHP func

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信