Imported Upstream version 2.7
[ossec-hids.git] / src / os_maild / sendmail.c
index 92157a7..5b0fd6f 100755 (executable)
@@ -1,11 +1,12 @@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/os_maild/sendmail.c, 2011/09/08 dcid Exp $
+ */
 
 /* Copyright (C) 2009 Trend Micro Inc.
  * All rights reserved.
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 2) as published by the FSF - Free Software 
+ * License (version 2) as published by the FSF - Free Software
  * Foundation
  */
 
@@ -64,7 +65,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
 
 
     /* Connecting to the smtp server */        
-    socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, mail->smtpserver);
+    socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, mail->smtpserver, 0);
     if(socket < 0)
     {
         return(socket);
@@ -109,7 +110,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
                     if(msg)
                         free(msg);
                     close(socket);
-                    return(OS_INVALID);    
+                    return(OS_INVALID);
                 }
             }
             else
@@ -152,7 +153,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
     /* Additional RCPT to */
     final_to[0] = '\0';
     final_to_sz = sizeof(final_to) -2;
-    
+
     if(mail->gran_to)
     {
         i = 0;
@@ -185,7 +186,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
             snprintf(snd_msg,127, TO, mail->gran_to[i]);
             strncat(final_to, snd_msg, final_to_sz);
             final_to_sz -= strlen(snd_msg) +2;
-            
+
             i++;
             continue;
         }
@@ -218,7 +219,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
 
     /* Sending date */
     memset(snd_msg,'\0',128);
-    
+
 
     /* Solaris doesn't have the "%z", so we set the timezone to 0. */
     #ifdef SOLARIS
@@ -226,7 +227,7 @@ int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg)
     #else
     strftime(snd_msg, 127, "Date: %a, %d %b %Y %T %z\r\n",p);
     #endif
-    
+
     OS_SendTCP(socket,snd_msg);
 
 
@@ -287,7 +288,7 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
     MailNode *mailmsg;
 
     additional_to[0] = '\0';
-    
+
     /* If there is no sms message, we attempt to get from the
      * email list.
      */
@@ -297,10 +298,10 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
     {
         merror("%s: No email to be sent. Inconsistent state.",ARGV0);
     }
-    
+
 
     /* Connecting to the smtp server */        
-    socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, mail->smtpserver);
+    socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, mail->smtpserver, 0);
     if(socket < 0)
     {
         return(socket);
@@ -345,7 +346,7 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
                     if(msg)
                         free(msg);
                     close(socket);
-                    return(OS_INVALID);    
+                    return(OS_INVALID);
                 }
             }
             else
@@ -438,9 +439,9 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
                     free(msg);
 
                 i++;
-                continue;    
+                continue;
             }
-            
+
             MAIL_DEBUG("DEBUG: Sent '%s', received: '%s'", snd_msg, msg);
             free(msg);
             i++;
@@ -484,7 +485,7 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
             {
                 break;
             }
-            
+
             memset(snd_msg,'\0',128);
             snprintf(snd_msg,127, TO, mail->to[i]);
             OS_SendTCP(socket,snd_msg);
@@ -525,7 +526,7 @@ int OS_Sendmail(MailConfig *mail, struct tm *p)
     #else
     strftime(snd_msg, 127, "Date: %a, %d %b %Y %T %z\r\n",p);
     #endif
-                            
+
     OS_SendTCP(socket,snd_msg);