From db4ba78e811d6c9996496eb9f091e0ecc967608f Mon Sep 17 00:00:00 2001
From: root <root@squid.(none)>
Date: Sat, 26 May 2012 20:35:09 -0700
Subject: [PATCH] smtp_state_helo: Sends a user supplied HELO string
 smtp_state_ehlo: Sends a user supplied EHLO string

This allows a user to set a customized HELO/EHLO
string. It will default to the servers hostname
if one is not supplied by the user.
---
 lib/smtp.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/smtp.c b/lib/smtp.c
index ae8d9a5..aed78ad 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -348,13 +348,19 @@ static CURLcode smtp_state_ehlo(struct connectdata *conn)
 {
   CURLcode result;
   struct smtp_conn *smtpc = &conn->proto.smtpc;
+  struct SessionHandle *data = conn->data;
 
   smtpc->authmechs = 0;         /* No known authentication mechanisms yet. */
   smtpc->authused = 0;          /* Clear the authentication mechanism used
                                    for esmtp connections */
 
   /* send EHLO */
-  result = Curl_pp_sendf(&smtpc->pp, "EHLO %s", smtpc->domain);
+  if (!data->set.str[STRING_MAIL_HELO]) {
+    result = Curl_pp_sendf(&smtpc->pp, "EHLO %s", smtpc->domain);
+  }
+  else {
+    result = Curl_pp_sendf(&smtpc->pp, "EHLO %s", data->set.str[STRING_MAIL_HELO]);
+  }
 
   if(result)
     return result;
@@ -368,12 +374,18 @@ static CURLcode smtp_state_helo(struct connectdata *conn)
 {
   CURLcode result;
   struct smtp_conn *smtpc = &conn->proto.smtpc;
+  struct SessionHandle *data = conn->data;
 
   smtpc->authused = 0;          /* No authentication mechanism used in smtp
                                    connections */
 
   /* send HELO */
-  result = Curl_pp_sendf(&smtpc->pp, "HELO %s", smtpc->domain);
+  if(!data->set.str[STRING_MAIL_HELO]) {
+    result = Curl_pp_send(&smtpc->pp, "HELO %s", smtpc->domain);
+  }
+  else {
+    result = Curl_pp_sendf(&smtpc->pp, "HELO %s", data->set.str[STRING_MAIL_HELO]);
+  }
 
   if(result)
     return result;
-- 
1.5.4.3

