dsizd368332 2014-02-21 16:19
浏览 55
已采纳

在php上创建自动发送电子邮件应用程序时的概念是什么?

I have an website running, and what I want to do is create a Table that has listed all the email that need to be sent, with all the information in it. Example:

CREATE TABLE Send_Email
ID INT,
To VARCHAR(130),
Subject VARCHAR(130),
Message TEXT

What I want to do - and don't know how - is to check automatically if there is any record on this table, if there is: Send the email(s) and delete the row(s).

What I don't know is what is the concept when building something like this. Where to put it? How to check it automatically? Do I put the loop code on my main "master controller" and run it every time someone loads up one of my pages? This looks like it will affect performance.

  • 写回答

1条回答 默认 最新

  • doudu2404 2014-02-21 16:24
    关注

    This is the ideal task for a cron job (or any equivalent system). You need a service running on your server, which will periodically perform your wanted action. If you have your own server, this can be done for sure, but if you have your site hosted somewhere you need to check with the provider for this possibility.

    EDIT: If you can't use scheduled jobs, it might still be reasonable to perform the action somewhere else. For example, if the records in the table are inserted only from within your website, you could configure it to forward an email as soon as it is sent by the writer, avoiding the need to regularly check the database (in fact, you wouldn't need a table at all). It is obvious though that this solution is not as flexible as the other one, and that it is applicable only in particular situations.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler