[英]Python is not sending email when run from PHP
I'm working on a small site that runs via PHP a Python file. 我正在一个通过PHP运行Python文件的小型站点。
The python file takes a few minutes to run and when finished send an email informing you that the process has finished running. python文件需要花费几分钟才能运行,完成后会发送电子邮件通知您该进程已完成运行。
If I run the script manually from Terminal the email was sent. 如果我从终端手动运行脚本,则会发送电子邮件。 But when I try to run it from PHP using
system()
function does not send the email. 但是,当我尝试使用
system()
函数从PHP运行它时,不会发送电子邮件。
I tested the issue by dumping and running the same line that system() would run via PHP, so no typos when running the test. 我通过转储并运行与PHP一起运行system()的同一行来测试了该问题,因此在运行测试时没有错别字。
The python file tweets content from a CSV file with a random interval between a range of seconds and once all the tweets are sent it notifies via email to the user who run the script. python文件以秒为单位的随机间隔在CSV文件中鸣叫内容,一旦发送完所有鸣叫,它将通过电子邮件通知运行脚本的用户。
tweet.py {csv_file} {interval_min} {interval_max} {email_to_notify_when_finished}
python tweet.py test.csv 10 20 some@email.com
Other notes: 其他说明:
ec2-user
user, the same user that I used for manually testing this issue. ec2-user
用户,与我手动测试此问题所使用ec2-user
相同。 ps -aux
shows me that the scripts are correctly run by ec2-user
. ps -aux
告诉我脚本由ec2-user
正确运行。 My specs: 我的规格:
Can you try to narrow down what the python script is doing? 您能尝试缩小python脚本的作用吗? You can try something as simple as print statements or write to file to confirm how much of your code is being run by the program when it is run by PhP.
您可以尝试使用诸如打印语句之类的简单操作,也可以尝试写入文件以确认程序在由PhP运行时正在运行多少代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.