KSMTP

KSmtp - a job-based API for interacting with SMTP servers

Purpose

This library provides a job-based API for interacting with an SMTP server. Its design follows the design KIMAP.

Description

Sample usage:

void MyClass::login()
{
m_session = new KSmtp::Session("smtp.example.com", 587, KSmtp::Session::StartAndWait, this);
// Start authentication
KSmtp::LoginJob* login = new KSmtp::LoginJob(m_session);
login->setUseTls(true);
login->setUserName("[email protected]");
login->setPassword("password");
connect(login, SIGNAL(result(KJob*)), this, SLOT(loginResult(KJob*)));
login->start();
}
void MyClass::loginResult(KJob* job)
{
if (m_session->state() != KSmtp::Session::Authenticated) {
... // handle error
return;
}
// Create a new KMime::Message
msg->from()->fromUnicodeString("[email protected]", "utf-8");
msg->to()->fromUnicodeString("[email protected]", "utf-8");
msg->subject()->fromUnicodeString("Hi there!", "utf-8");
msg->contentType()->setMimeType("text/plain");
msg->contentTransferEncoding()->setEncoding(KMime::Headers::CEquPr);
// Assembles and encodes the message
msg->assemble();
const QByteArray content = msg->encodedContent(true) + "\r\n";
// Start sending the message
KSmtp::SendJob* send = new KSmtp::SendJob(m_session);
send->setData(content);
send->setSender("[email protected]");
connect(send, SIGNAL(result(KJob*)), SLOT(sendResult(KJob*)));
send->start();
}
Author(s):
The major authors of this library are:
Christophe Laveault <chris.nosp@m.toph.nosp@m.e@bet.nosp@m.teri.nosp@m.nbox..nosp@m.com>
Maintainer(s):
Gregory Schlomoff <greg@.nosp@m.bett.nosp@m.erinb.nosp@m.ox.c.nosp@m.om>,
License(s):
LGPLv2
The Session class.
Definition: session.h:23
void setBcc(const QStringList &bcc)
Add recipients.
Definition: sendjob.cpp:82
void setTo(const QStringList &to)
Add recipients.
Definition: sendjob.cpp:70
The LoginJob class.
Definition: loginjob.h:21
void setData(const QByteArray &data)
Set the actual message data.
Definition: sendjob.cpp:88
@ Authenticated
The Session is ready to send email.
Definition: session.h:33
The SendJob class.
Definition: sendjob.h:21
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:07:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.