QT创建者发送短信
QT Creator send SMS message
>无法弄清楚如何使用在 Ubuntu 16.04 上运行的 QT Creator 向手机发送短信。 可以使用 MS 视觉C++轻松完成
下面的代码在Windows Visual C++/CLI中工作正常。 在 Ubuntu 16.04 上的 QT Creator 中是否有与此或等效的代码等效的代码?
using namespace System::Net; //need for Webclient
using namespace System::Net::Mail; //need for sending SMS text message via email
//send an SMS message via email:
MailAddress^ to = gcnew MailAddress("760xxxxxxx@vmobl.com"); //the generic Virgin Mobile format
MailAddress^ from = gcnew MailAddress("xxxxxxxx@roadrunner.com"); //hosted by Time Warner Cable
MailMessage^ message = gcnew MailMessage(from,to);
message->Subject = "What's up?"; //the subject line
message->Body = Globals::TextMsg; //TestMsg is a string; the body of the message to be sent
SmtpClient^ client = gcnew SmtpClient; //create a client
client->Host::set("mail.twc.com"); //the outgoing SMTP mail server of Time Warner
client->Send(message); //send message to phone
client->~SmtpClient(); //destroy the client
8个小时的脑痛就解决了。要使用 QTcreator(在我的情况下为 5.5)执行与上述相同的操作,除了在 Ubuntu(在我的例子中为 16.04)中,并将最令人发指、最可憎和真正令人作呕的 C# 代码替换为纯粹、高贵和美丽的C++,请执行以下操作:
使用时代华纳 SMTP 服务器(而不是 Gmail 服务器):
1. 转到 https://github.com/xcoder123/SimpleSmtp_SSL_QT5/tree/master/smtp
2. 下载、克隆或解压缩;然后在 QT 3 中打开这个优秀的项目
。 在 smtp.h 中进行以下更改:#include <QtNetwork/QTcpSocket> //add this to work with Time Warner Cable
">
在公共场合:Smtp 将"int port = 465"更改为"int port = 587"//gmail 私下使用 465,时代华纳私下使用 587
://QSslSocket *socket; //this works with Gmail
QTcpSocket *socket; //this works with Time Warner Cable
4。 在 smtp 中进行以下更改.cpp:
在 Smtp::Smtp
中//socket = new QSslSocket(this); //this works with Gmail
socket = new QTcpSocket(this); //this works with Time Warner Cable
在无效 Smtp::sendMail//socket->connectToHostEncrypted(host, port); //"smtp.gmail.com" and 465 for gmail TLS
socket->connectToHost(host, port); //Time Warner doesn't use Encrypted
在无效 Smtp::readyRead//socket->startClientEncryption(); //Time Warner doesn't use Encryption, so comment all this out
// if(!socket->waitForEncrypted(timeout))
// {
// qDebug() << socket->errorString();
// state = Close;
// }
//*t << QByteArray().append(user).toBase64() << "rn";
*t << QByteArray().append(user) << "rn"; //Time Warner doesn't use base64
有了这个,可以从UI发送电子邮件。 要向维珍移动发送短信,请将收件人替换为 10 位数的电话号码 @vmobl.com。 示例:"7609999999@vmobl.com"。 短信将是"主题:"加上主题。 正文不会出现,因此留空。 一开始我找不到简单的方法来摆脱"主题:"。
- Qt创建者:加载位于子目录中的项目文件
- Qt创建者-如何删除Clang代码模型
- 使用Cmake将插件安装到独立的Qt Designer(不是Qt创建者)中
- RTLD_NOW和 dlopen 未在此范围内声明 qt 创建者 vulkan dlopen
- 原版Qt创建者是否有C++标准库
- QT创建者 - selecteddate()不起作用
- 当将QT创建者与CMAKE一起使用时,为什么我不必手动链接MSVC库
- QT创建者:Arm-Linux-androideabi-G :找不到
- 创建小部件的GUI菜单不会出现在QT创建者中
- Qt 创建者在我将项目移动到另一个地方后仍然使用源项目
- QT创建者(4.2.2)编辑器中的独特指针导航
- 调整QT创建者的复选框
- QT创建者的错误
- Mac上使用QT创建者的链接增强
- QT创建者中对CMU狮身人面像函数的未定义引用
- QT创建者:简单程序未解决的外部符号和外部符号错误
- 页面未在此范围内声明 - qt 创建者 - PoDoFo
- QT创建者添加MQTT库
- 如何将scintilla组件添加到QT创建者C 项目中
- 错误编译QT创建者 / QT窗口小部件示例