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

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

问题描述

我设法发送了多封电子邮件(在此处查看).我坚持通过 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 脚本——如果它直接从浏览器启动,就可以编写一个可以工作的脚本.然后安排相同的 PHP 文件在 cron 中运行,以此为指导:

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.

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

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