使用 Qt 和 Qt 发送邮件php.exe
我为我的工作创建的程序有问题。这是一个用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来是配置问题。检查您的 php.ini,特别是 SMTP 设置。
It seems like config problem. Check your php.ini and specially SMTP settings.