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("example@example.com");
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("sender@example.com", "utf-8");
msg->to()->fromUnicodeString("recipient@example.com", "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("sender@example.com");
send->setTo("recipient@example.com");
send->setBcc("hidden-recipient@example.com");
connect(send, SIGNAL(result(KJob*)), SLOT(sendResult(KJob*)));
send->start();
}
The LoginJob class.
Definition loginjob.h:22
The SendJob class.
Definition sendjob.h:22
void setBcc(const QStringList &bcc)
Add recipients.
Definition sendjob.cpp:87
void setData(const QByteArray &data)
Set the actual message data.
Definition sendjob.cpp:93
void setTo(const QStringList &to)
Add recipients.
Definition sendjob.cpp:75
The Session class.
Definition session.h:24
@ Authenticated
The Session is ready to send email.
Definition session.h:33
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.