mailtransport
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 )
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()) );
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();
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()
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:52 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.