我为我的工作创建的程序有问题。这是一个用Qt开发的C++程序。
我想发送电子邮件,所以我在 C++ 中调用 php:
QStringList l;
QString msg(mail.c_str());
l << "C: //sql.php"; //my function which send an email
l << msg; // my email
this->_php->start("C:\\Program Files\\wamp\\bin\\php\\php5.3.8\\php.exe", l);
此代码有效,php 没有写入错误。所以看看我在 php 中的其他功能(myemail@xxx.fr
不是我的真实地址 :p,我已经隐藏它来问我的问题)
$headers = 'From: "xxx"<noreply@xxx.fr>' . "\n";
$headers .='Content-Type: text/html; charset="iso-8859-1"' . "\n";
$headers .='Content-Transfer-Encoding: 8bit' . "\n";
$obj = "my_object";
$msg = "<html><head></head><body>awdadwawdawd</body></html>";
if (mail("myemail@xxx.fr", $obj, $msg, $headers) == true)
echo "ok";
else
echo "fail";
之所以可行,是因为在我的 C++ 程序上打印了“ok”。
但是这封电子邮件没有到达我的电子邮箱。
当我尝试在 wamp 中启动 php 的功能时(使用本地主机....)它正在工作,因为我收到了这封邮件。但是当我尝试使用我的 C++ 程序和 php.exe
时,电子邮件没有到达。
有人有想法或建议来解决我的问题吗?
最佳答案
看来是配置问题。检查您的 php.ini,特别是 SMTP 设置。
php -i | findstr SMTP //check SMTP server
php -i | findstr "Configuration File" //to check php.ini location
关于php - 使用 Qt 和 php.exe 发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7754568/