资源简介
在网上找了好久Qt实现smtp发送邮件的简易版本,一直没有找到,最终在github上找到别人六七年前写的开源代码,经过改良能够在Qt5.11.1上运行,希望那个对大家有用

代码片段和文件信息
/*
Copyright (c) 2012 Nicholas Smith
Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files (the “Software“) to deal in the Software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and/or sell copies of the Software and to permit persons to whom the Software is furnished to do so subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
#include “smtp.h“
Smtp::Smtp(const QString &serverName const QString &username const QString &password const QString &from const QStringList &to const QString &subject const QString &body)
{
server = serverName; //your server name
user = username; //your SMTP username
pass = password; //your SMTP password
user = user.toLocal8Bit().tobase64();
pass = pass.toLocal8Bit().tobase64();
x = 1;
int recipCount = 0;
socket = new QTcpSocket(this);
connect(socket SIGNAL(readyRead()) this SLOT(readyRead()));
connect(socket SIGNAL(connected()) this SLOT(connected() ) );
connect(socket SIGNAL(error(QAbstractSocket::SocketError)) this
SLOT(errorReceived(QAbstractSocket::SocketError)));
connect(socket SIGNAL(stateChanged( QAbstractSocket::SocketState)) this
SLOT(stateChanged(QAbstractSocket::SocketState)));
connect(socket SIGNAL(disconnected()) this
SLOT(disconnected()));
qDebug() << “Signals created“;
for(recipCount = 0; recipCount < to.count(); recipCount++)
{
message.append(“To: “ + to.at(recipCount) + “\n“);
}
message.append(“From: “ + from + “\n“);
message.append(“Subject: “ + subject + “\n“);
message.append(“Mime-Version: 1.0;\n“);
message.append(“Content-Type: text/html; charset=\“utf8\“;\n“);
message.append(“Content-Transfer-Encoding: 8bit;\n“);
message.append(“\n“);
qDebug() << “body is: “ << body;
message.append(body);
message.replace(QString::fromLatin1( “\n“ ) QString::fromLatin1( “\r\n“));
message.replace(QString::fromLatin1( “\r\n.\r\n“ ) QString::fromLatin1( “\r\n..\r\n“ ) );
this->from = from;
rcpt = to.at(0);
recips = to;
state = Init;
socket->connectToHost(server 25);
if(socket->waitForConnected(30000))
{
qDebug(“connected“);
}
t = new QTextStream( socket );
}
Smtp::~Smtp()
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-06-05 14:30 Qt-SMTP-master\
文件 197 2012-06-05 14:30 Qt-SMTP-master\README
目录 0 2018-08-30 13:59 Qt-SMTP-master\example\
文件 172 2018-08-30 13:59 Qt-SMTP-master\example\main.cpp
文件 15378 2018-08-30 13:04 Qt-SMTP-master\example\Smtptest.pro.user.-1
文件 392 2018-08-30 13:58 Qt-SMTP-master\example\Smtptest.pro
文件 19350 2018-08-30 13:54 Qt-SMTP-master\example\Smtptest.pro.user
文件 1120 2012-06-05 14:30 Qt-SMTP-master\example\mainwindow.cpp
文件 345 2012-06-05 14:30 Qt-SMTP-master\example\mainwindow.h
文件 4715 2012-06-05 14:30 Qt-SMTP-master\example\mainwindow.ui
文件 5807 2012-06-05 14:30 Qt-SMTP-master\smtp.cpp
文件 2237 2012-06-05 14:30 Qt-SMTP-master\smtp.h
相关资源
- 酒店管理系统基于Qt Creator5)
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- C 餐厅叫号系统(QT平)
- QT 实现文件下载
- qt图像处理
- QT,JPEG解码源代码(已完成)
- Qt 播放音频文件
- Qt 读取16进制的data文件
- MQTT+串口(usart)透传
- 易语言QQTEA算法源码
- VC工程转Qt工程文件的工具
- MQTT推送Demo
- 基于Linux、QT的视频监控系统的设计与
- Qt 百度地图 定位
- QT酷炫界面开发指南《QmlBook》
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
- MQTT_3.1protocol_Specific中文版
- 在QT中使用RTP进行视频的采集和传输
- Mini6410 Qt4和Qtopia编程开发指南
- Qt实现Code39条形码
- qt_ffmpeg_mp4_export_and_import.zip
- QT5.5入门与项目实战
- Huffman Compress 霍夫曼编码 压缩 解压缩
评论
共有 条评论