From 1e54cba4d328f71b7d1e3d7dfc0b8b95344a4d01 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 11 May 2000 20:11:07 +0000 Subject: providers/smtp/camel-smtp-transport.c: updated smtp_helo to more closely comply with RFC 821 standards svn path=/trunk/; revision=2991 --- camel/ChangeLog | 5 +++++ camel/providers/smtp/camel-smtp-transport.c | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 5385940204..0d22e830e5 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2000-05-11 Jeffrey Stedfast + + * providers/smtp/camel-smtp-transport.c: (smtp_helo): + Updated to more closely comply with RFC 821 standards + 2000-05-11 NotZed * camel-mime-part.c (write_to_stream): Unref the filter after diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 57d14d7fe3..e76815a795 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -436,24 +436,20 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) { /* say hello to the server */ gchar *cmdbuf, *respbuf = NULL; - gchar localhost[MAXHOSTNAMELEN + MAXHOSTNAMELEN + 2]; - gchar domainname[MAXHOSTNAMELEN]; - - /* get the localhost name */ - memset(localhost, 0, sizeof(localhost)); - gethostname (localhost, MAXHOSTNAMELEN); - memset(domainname, 0, sizeof(domainname)); - getdomainname(domainname, MAXHOSTNAMELEN); - if (*domainname && strcmp(domainname, "(none)")) { - strcat(localhost, "."); - strcat(localhost, domainname); - } + struct sockaddr_in localaddr; + guint32 addrlen; + struct hostent *host; + + /* get the local host name */ + addrlen = sizeof(localaddr); + getsockname(sock, (struct sockaddr*)&localaddr, &addrlen); + host = gethostbyaddr((gchar *)&localaddr.sin_addr, sizeof(localaddr.sin_addr), AF_INET); /* hiya server! how are you today? */ if (smtp_is_esmtp) - cmdbuf = g_strdup_printf ("EHLO %s\r\n", localhost); + cmdbuf = g_strdup_printf ("EHLO %s\r\n", host->h_name); else - cmdbuf = g_strdup_printf ("HELO %s\r\n", localhost); + cmdbuf = g_strdup_printf ("HELO %s\r\n", host->h_name); if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf), ex) == -1) { g_free(cmdbuf); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, -- cgit