mailtransport
24#include "sendmailjob.h"
27#include <KLocalizedString>
29#include <QtCore/QProcess>
30#include <QtCore/QBuffer>
32using namespace MailTransport;
38class SendMailJobPrivate
46 :
TransportJob( transport, parent ), d( new SendMailJobPrivate )
48 d->process =
new QProcess(
this );
50 SIGNAL(finished(
int,QProcess::ExitStatus)),
51 SLOT(sendmailExited(
int,QProcess::ExitStatus)) );
52 connect( d->process, SIGNAL(error(QProcess::ProcessError)),
53 SLOT(receivedError()) );
54 connect( d->process, SIGNAL(readyReadStandardError()),
55 SLOT(receivedStdErr()) );
58SendmailJob::~ SendmailJob()
65 QStringList arguments;
66 arguments << QLatin1String(
"-i" ) << QLatin1String(
"-f" )
68 d->process->start(
transport()->host(), arguments );
70 if ( !d->process->waitForStarted() ) {
71 setError( UserDefinedError );
72 setErrorText( i18n(
"Failed to execute mailer program %1",
transport()->host() ) );
75 d->process->write(
buffer()->readAll() );
76 d->process->closeWriteChannel();
80void SendmailJob::sendmailExited(
int exitCode, QProcess::ExitStatus exitStatus )
82 if ( exitStatus != 0 || exitCode != 0 ) {
83 setError( UserDefinedError );
84 if ( d->lastError.isEmpty() ) {
85 setErrorText( i18n(
"Sendmail exited abnormally." ) );
87 setErrorText( i18n(
"Sendmail exited abnormally: %1", d->lastError ) );
93void SendmailJob::receivedError()
95 d->lastError += d->process->errorString();
98void SendmailJob::receivedStdErr()
100 d->lastError += QLatin1String( d->process->readAllStandardError() );
103bool SendmailJob::doKill()
virtual void doStart()
Do the actual work, implement in your subclass.
SendmailJob(Transport *transport, QObject *parent=0)
Creates a SendmailJob.
Abstract base class for all mail transport jobs.
Transport * transport() const
Returns the Transport object containing the mail transport settings.
QBuffer * buffer()
Returns a QBuffer opened on the message data.
QString sender() const
Returns the sender of the mail.
QStringList bcc() const
Returns the "Bcc" receiver(s) of the mail.
QStringList to() const
Returns the "To" receiver(s) of the mail.
QStringList cc() const
Returns the "Cc" receiver(s) of the mail.
Represents the settings of a specific mail transport.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by
doxygen 1.10.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.