24 #include "sendmailjob.h"
25 #include "transport.h"
27 #include <KLocalizedString>
29 #include <QtCore/QProcess>
30 #include <QtCore/QBuffer>
32 using namespace MailTransport;
38 class SendMailJobPrivate
46 :
TransportJob( transport, parent ), d( new SendMailJobPrivate )
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()) );
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();
80 void 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 ) );
93 void SendmailJob::receivedError()
95 d->lastError += d->process->errorString();
98 void SendmailJob::receivedStdErr()
100 d->lastError +=
QLatin1String( d->process->readAllStandardError() );
103 bool SendmailJob::doKill()
QStringList bcc() const
Returns the "Bcc" receiver(s) of the mail.
virtual ~SendmailJob()
Destroys this job.
QStringList cc() const
Returns the "Cc" receiver(s) of the mail.
QString sender() const
Returns the sender of the mail.
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.
Represents the settings of a specific mail transport.
QStringList to() const
Returns the "To" receiver(s) of the mail.
Transport * transport() const
Returns the Transport object containing the mail transport settings.
QBuffer * buffer()
Returns a QBuffer opened on the message data.