如何发送电子邮件通过cron工作usng PHP mysql [英] How to send emails via cron job usng PHP mysql

查看:154
本文介绍了如何发送电子邮件通过cron工作usng PHP mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法发送多封电子邮件(查看此处).i我不得不通过cron发送自动电子邮件。

i managed to send multiple emails (check here).i am stuck with sending automated emails via cron.

这是我需要的 - 当管理员发送电子邮件时,我将消息,电子邮件,事件日期存储在数据库中。现在我试图设置一个cron工作,从表中发送电子邮件到所有这些ID,并附带消息,作为提醒。我不熟悉cron作业脚本,任何人都可以帮助指导我正确的方式来编写我可以放在cron标签中的脚本。我计划发送两封邮件 - 一天在事件发生前和事件发生当天。

This is what i need - while the admin send emails, i store the message, emails, event date in the database. now i am trying to set a cron job to send emails to all these ids from the table with the message i have as a reminder. i am not familiar with cron job scripting, can anyone help in guiding me the right way to write script that i can place in cron tab. I am planning to send two mails - one day exactly before the event and on the day of event.thanks

推荐答案

只需写一个正常的PHP脚本 - 如果直接从浏览器启动,它将会工作。然后安排在cron中运行相同的PHP文件,以此作为指导:

Just write a normal PHP script -- make one that will work if it's launched directly from the browser. Then schedule that very same PHP file to run in cron, using this as a guide:

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

基本上,使用开头的值,指定计划(分钟,小时,星期几,月份等)。然后将其运行的用户设置为可能是apache或任何您的Web服务器守护程序运行的用户。然后设置cron运行的命令为 php php_email_script.php (其中php_email_script.php是您的PHP文件的名称。

Basically, using the values at the beginning, specify the schedule (minute, hour, day of week, day of month, etc.). Then set the user it runs as, which is likely to be "apache" or whatever your web server daemon is running under. Then set the "command" that cron is running to be php php_email_script.php (where "php_email_script.php" is the name of your PHP file.

这篇关于如何发送电子邮件通过cron工作usng PHP mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆