[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [PATCH] kio_smtp send failure when no hostname
From: "Aaron J. Seigo" <aseigo () olympusproject ! org>
Date: 2002-02-17 7:31:54
[Download RAW message or body]
hi...
when there is no hostname set on the system kmail is running on then sending
may fail due to a lack of a domain in the HELO.. the attatched patch corrects
this by supplying a fake domain when a real one is lacking.
it also adds the ability to add a hostname= to the put query string to set
this to a user defined setting ... something for kmail in 3.1 ;-)
the patch was tested successfully by John Brajkovic, who orginally reported
the problem on irc tonight.
comments? suggestions? ok to commit?
--
Aaron Seigo
["kio_smtp.patch" (text/x-diff)]
Index: smtp.cc
===================================================================
RCS file: /home/kde/kdebase/kioslave/smtp/smtp.cc,v
retrieving revision 1.85
diff -u -3 -d -p -r1.85 smtp.cc
--- smtp.cc 2002/01/17 06:19:47 1.85
+++ smtp.cc 2002/02/17 07:28:45
@@ -166,7 +166,8 @@ void SMTPProtocol::special(const QByteAr
// cc=emailaddress
// bcc=emailaddress
// subject=text
-// profile=text (this will override the "host" setting
+// profile=text (this will override the "host" setting)
+// hostname=text (used in the HELO)
void SMTPProtocol::put(const KURL & url, int /*permissions */ ,
bool /*overwrite */ , bool /*resume */ )
{
@@ -174,6 +175,7 @@ void SMTPProtocol::put(const KURL & url,
QString subject = ASCII("missing subject");
QString profile = QString::null;
QString from = QString::null;
+ QString localHostname = QString::null;
QStringList recip, bcc, cc, temp_list;
bool headers = true;
@@ -204,6 +206,13 @@ void SMTPProtocol::put(const KURL & url,
temp_list.clear();
}
+ // grab the hostname to use in opening the connection if defined
+ GetAddresses(query, ASCII("hostname="), temp_list);
+ if (temp_list.count()) {
+ localHostname = temp_list.last();
+ temp_list.clear();
+ }
+
KEMailSettings *mset = new KEMailSettings;
KURL open_url = url;
if (profile == QString::null) {
@@ -254,7 +263,7 @@ void SMTPProtocol::put(const KURL & url,
from.prepend(ASCII("MAIL FROM: <"));
from.append(ASCII(">"));
- if (!smtp_open())
+ if (!smtp_open(localHostname))
error(ERR_SERVICE_NOT_AVAILABLE,
i18n("SMTPProtocol::smtp_open failed (%1)").arg(open_url.
path()));
@@ -483,7 +492,7 @@ bool SMTPProtocol::command(const QString
return (getResponse(recv_buf, len) < 400);
}
-bool SMTPProtocol::smtp_open()
+bool SMTPProtocol::smtp_open(const QString& fakeHostname)
{
if (opened && (m_iOldPort == port(m_iPort))
&& (m_sOldServer == m_sServer) && (m_sOldUser == m_sUser)) {
@@ -506,7 +515,22 @@ bool SMTPProtocol::smtp_open()
memset(ehlobuf.buffer().data(), 0, DEFAULT_EHLO_BUFFER);
char hostname[100];
- gethostname(hostname, 100);
+ memset(hostname, '\0', 100);
+
+ if (fakeHostname != QString::null)
+ {
+ strncpy(hostname, fakeHostname.latin1(), 99);
+ }
+ else
+ {
+ gethostname(hostname, 100);
+ }
+
+ if (hostname[0] == '\0')
+ {
+ strncpy(hostname, "anon.penet.fi", strlen("anon.penet.fi") + 1);
+ }
+
if (!command
(ASCII("EHLO " + QCString(hostname, 100)), ehlobuf.buffer().data(),
5119)) {
Index: smtp.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/smtp/smtp.h,v
retrieving revision 1.30
diff -u -3 -d -p -r1.30 smtp.h
--- smtp.h 2002/01/13 10:18:06 1.30
+++ smtp.h 2002/02/17 07:28:45
@@ -52,7 +52,7 @@ public:
protected:
- bool smtp_open();
+ bool smtp_open(const QString& fakeHostname = QString::null);
void smtp_close();
bool command(const QString & buf, char *r_buf =
NULL, unsigned int r_len = 0);
_______________________________________________
kmail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic