{
connect( socket, SIGNAL(readyRead()), this, SLOT( readyRead() ) );
connect( socket, SIGNAL( connected()), this, SLOT( connected() ) );
connect(socket, SIGNAL(disconnected()), this,SLOT(disconnected()));
message = "To: " + to + "\n";
message.append("From: " + from + "\n");
message.append("Subject: " + subject + "\n");
//Let's intitiate multipart MIME with cutting boundary "frontier"
message.append("MIME-Version: 1.0\n");
message.append("Content-Type: multipart/mixed; boundary=frontier\n\n");
message.append( "--frontier\n" );
//message.append( "Content-Type: text/html\n\n" ); //Uncomment this for HTML
formating, coment the line below
message.append( "Content-Type: text/html\n\n" );
message.append(body);
message.append("\n\n");
message.append( "--frontier--\n" );
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;
state = Init;
socket->connectToHost( address,port);//"172.17.72.36", 25);
if(socket->waitForConnected ( 30000 ))
{qDebug("connected"); }
}
Smtp::Smtp( const QString &from, const QString &to, const QString &subject , const QString &body ,const QString &address,int port)
{
socket = new QTcpSocket(this);
connect( socket, SIGNAL(readyRead()), this, SLOT( readyRead() ) );
connect( socket, SIGNAL( connected()), this, SLOT( connected() ) );
connect(socket, SIGNAL(disconnected()), this,SLOT(disconnected()));
message = "To: " + to + "\n";
message.append("From: " + from + "\n");
message.append("Subject: " + subject + "\n");
//Let's intitiate multipart MIME with cutting boundary "frontier"
message.append("MIME-Version: 1.0\n");
message.append("Content-Type: multipart/mixed; boundary=frontier\n\n");
message.append( "--frontier\n" );
//message.append( "Content-Type: text/html\n\n" ); //Uncomment this for HTML
formating, coment the line below
message.append( "Content-Type: text/html\n\n" );
message.append(body);
message.append("\n\n");
message.append( "--frontier--\n" );
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;
state = Init;
socket->connectToHost( address,port);//"172.17.72.36", 25);
t = new QTextStream( socket );
if(socket->waitForConnected ( 30000 ))
{qDebug("connected"); }
}
To copy to clipboard, switch view to plain text mode
Bookmarks