php - 使用 Qt 和 php.exe 发送邮件

标签 php c++ qt smtp wamp

我为我的工作创建的程序有问题。这是一个用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/

相关文章:

php - 如何使用 PHP 从上传到本地主机的一个 html 文件重定向到磁盘上的另一个 html 文件?

c++ - 如何根据 boost 版本有选择地包含 boost header

c++ - 仅在 C/C++ 中使用 header 时?

c++ - 体系结构 x86_64 : "_CFBundleCopyResourceURL", 的 undefined symbol

c++ - Qt 找不到 Qt5Core Qt5Widgets 等

Javascript 使用输入创建用户名

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - CakePHP/MySQL : find with a condition for model itself and an assigned model

C++ : convert date/time string to tm struct

qt - 在 QtCreator 中导入 CMake 项目