Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Trojitá
Commits
0083eea5
Commit
0083eea5
authored
May 11, 2009
by
Jan Kundrát
Browse files
Untested attempt at sending mails via SMTP
parent
888f916f
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
0083eea5
...
...
@@ -92,6 +92,7 @@ set(libStreams_SRCS
set
(
libMSA_SRCS
${
CMAKE_CURRENT_SOURCE_DIR
}
/MSA/AbstractMSA.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/MSA/Sendmail.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/MSA/SMTP.cpp
)
set
(
trojita_SRCS
...
...
Gui/ComposeWidget.cpp
View file @
0083eea5
...
...
@@ -15,6 +15,7 @@
#include "SettingsNames.h"
#include "RecipientsWidget.h"
#include "MSA/Sendmail.h"
#include "MSA/SMTP.h"
#include "Imap/Parser/3rdparty/kmime_util.h"
...
...
@@ -62,8 +63,12 @@ void ComposeWidget::send()
QSettings
s
;
MSA
::
AbstractMSA
*
msa
=
0
;
if
(
s
.
value
(
SettingsNames
::
msaMethodKey
).
toString
()
==
SettingsNames
::
methodSMTP
)
{
qFatal
(
"SMTP not implemented yet, sorry"
);
return
;
msa
=
new
MSA
::
SMTP
(
this
,
s
.
value
(
SettingsNames
::
smtpHostKey
).
toString
(),
s
.
value
(
SettingsNames
::
smtpPortKey
).
toInt
(),
false
,
false
,
// FIXME: encryption & startTls
s
.
value
(
SettingsNames
::
smtpAuthKey
).
toBool
(),
s
.
value
(
SettingsNames
::
smtpUserKey
).
toString
(),
s
.
value
(
SettingsNames
::
smtpPassKey
).
toString
()
);
}
else
{
QStringList
args
=
s
.
value
(
SettingsNames
::
sendmailKey
,
SettingsNames
::
sendmailDefaultCmd
).
toString
().
split
(
QLatin1Char
(
' '
)
);
Q_ASSERT
(
!
args
.
isEmpty
()
);
// FIXME
...
...
MSA/SMTP.cpp
0 → 100644
View file @
0083eea5
#include "SMTP.h"
namespace
MSA
{
SMTP
::
SMTP
(
QObject
*
parent
,
const
QString
&
host
,
quint16
port
,
bool
encryptedConnect
,
bool
startTls
,
bool
auth
,
const
QString
&
user
,
const
QString
&
pass
)
:
AbstractMSA
(
parent
),
_host
(
host
),
_port
(
port
),
_encryptedConnect
(
encryptedConnect
),
_startTls
(
startTls
),
_auth
(
auth
),
_user
(
user
),
_pass
(
pass
)
{
_qwwSmtp
=
new
QwwSmtpClient
(
this
);
// FIXME: handle SSL errors properly
connect
(
_qwwSmtp
,
SIGNAL
(
sslErrors
(
QList
<
QSslError
>
)),
_qwwSmtp
,
SLOT
(
ignoreSslErrors
())
);
connect
(
_qwwSmtp
,
SIGNAL
(
connected
()),
this
,
SIGNAL
(
sending
())
);
connect
(
_qwwSmtp
,
SIGNAL
(
done
(
bool
)),
this
,
SLOT
(
handleDone
(
bool
))
);
}
void
SMTP
::
cancel
()
{
_qwwSmtp
->
disconnectFromHost
();
}
void
SMTP
::
handleDone
(
bool
ok
)
{
qDebug
()
<<
"handleDone"
<<
ok
;
if
(
ok
)
emit
sent
();
else
emit
error
(
"blesmrt"
);
}
void
SMTP
::
sendMail
(
const
QStringList
&
to
,
const
QByteArray
&
data
)
{
emit
progressMax
(
data
.
size
()
);
emit
progress
(
0
);
emit
connecting
();
if
(
_encryptedConnect
)
_qwwSmtp
->
connectToHostEncrypted
(
_host
,
_port
);
else
_qwwSmtp
->
connectToHost
(
_host
,
_port
);
if
(
_startTls
)
_qwwSmtp
->
startTls
();
if
(
_auth
)
_qwwSmtp
->
authenticate
(
_user
,
_pass
);
emit
sending
();
// FIXME: later
_qwwSmtp
->
sendMail
(
/*FIXME*/
"kundratj@fzu.cz"
,
to
,
data
);
_qwwSmtp
->
disconnectFromHost
();
}
}
#include "SMTP.moc"
MSA/SMTP.h
0 → 100644
View file @
0083eea5
#ifndef SMTP_H
#define SMTP_H
#include "AbstractMSA.h"
#include "qwwsmtpclient/qwwsmtpclient.h"
namespace
MSA
{
class
SMTP
:
public
AbstractMSA
{
Q_OBJECT
public:
SMTP
(
QObject
*
parent
,
const
QString
&
host
,
quint16
port
,
bool
encryptedConnect
,
bool
startTls
,
bool
auth
,
const
QString
&
user
,
const
QString
&
pass
);
virtual
void
sendMail
(
const
QStringList
&
to
,
const
QByteArray
&
data
);
public
slots
:
virtual
void
cancel
();
void
handleDone
(
bool
ok
);
private:
QwwSmtpClient
*
_qwwSmtp
;
QString
_host
;
quint16
_port
;
bool
_encryptedConnect
;
bool
_startTls
;
bool
_auth
;
QString
_user
;
QString
_pass
;
};
}
#endif // SMTP_H
Jan Kundrát
@jkt
mentioned in commit
77ddd5d4
·
Jun 25, 2020
mentioned in commit
77ddd5d4
mentioned in commit 77ddd5d44f2bf4155d0c9b6f7d05f01713b32d5d
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment