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

发布于 2024-12-09 19:09:07 字数 1395 浏览 5 评论 0原文

我为我的工作创建的程序有问题。这是一个用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 中的其他函数 ([email protected]< /code> 不是我的真实地址:p,我隐藏了它来问我的问题)

    $headers = 'From: "xxx"<[email protected]>' . "\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("[email protected]", $obj, $msg, $headers) == true)
    echo "ok";
else
    echo "fail";

所以这是有效的,因为我的 C++ 程序上打印了“ok”。 但这封电子邮件没有到达我的电子邮箱。 当我尝试在 wamp 中启动 php 函数(使用 localhost...)时,它正在工作,因为我收到了这封邮件。但是当我尝试使用我的 C++ 程序和 php.exe 时,电子邮件没有到达。

有人有解决我的问题的想法或建议吗?

I have a problem with a program which I'm creating for my job. It's a C++ program which is developing with Qt.

I want to send an email, so I call php in C++:

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);

This code is working and php is not writing an error. So look my other function in php ([email protected] is not my real adress :p, I have hiding it for asking my question)

    $headers = 'From: "xxx"<[email protected]>' . "\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("[email protected]", $obj, $msg, $headers) == true)
    echo "ok";
else
    echo "fail";

So this is working because "ok" was print on my C++ program.
But this email wasn't arrived on my e-mail box.
When I try to launch the php's function in wamp (with localhost....) it's working because I received this mail. But when i try with my C++ program and php.exe, e-mails didn't arrived.

Someone have and idea or a suggestion to fix my problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尬尬 2024-12-16 19:09:07

看来是配置问题。检查您的 php.ini,特别是 SMTP 设置。

php -i | findstr SMTP //check SMTP server
php -i | findstr "Configuration File" //to check php.ini location

It seems like config problem. Check your php.ini and specially SMTP settings.

php -i | findstr SMTP //check SMTP server
php -i | findstr "Configuration File" //to check php.ini location
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文