@@ -123,6 +123,11 @@ int Read_Global(XML_NODE node, void *configp, void *mailp)
123123 const char * xml_heloserver = "helo_server" ;
124124 const char * xml_mailmaxperhour = "email_maxperhour" ;
125125
126+ const char * xml_auth_smtp = "auth_smtp" ;
127+ const char * xml_smtp_user = "smtp_user" ;
128+ const char * xml_smtp_pass = "smtp_password" ;
129+ const char * xml_secure_smtp = "secure_smtp" ;
130+
126131#ifdef LIBGEOIP_ENABLED
127132 const char * xml_geoip_db_path = "geoip_db_path" ;
128133 const char * xml_geoip6_db_path = "geoip6_db_path" ;
@@ -206,6 +211,42 @@ int Read_Global(XML_NODE node, void *configp, void *mailp)
206211 return (OS_INVALID );
207212 }
208213 }
214+ /* SMTP Authentication */
215+ else if (strcmp (node [i ]-> element , xml_auth_smtp ) == 0 )
216+ {
217+ if (strcmp (node [i ]-> content , "yes" ) == 0 )
218+ {
219+ if (Config ) Config -> authsmtp = 1 ;
220+ if (Mail ) Mail -> authsmtp = 1 ;
221+ }
222+ else if (strcmp (node [i ]-> content , "no" ) == 0 )
223+ {
224+ if (Config ) Config -> authsmtp = 0 ;
225+ if (Mail ) Mail -> authsmtp = 0 ;
226+ }
227+ else
228+ {
229+ return (OS_INVALID );
230+ }
231+ }
232+ /* Secure SMTP (SSL) */
233+ else if (strcmp (node [i ]-> element , xml_secure_smtp ) == 0 )
234+ {
235+ if (strcmp (node [i ]-> content , "yes" ) == 0 )
236+ {
237+ if (Config ) Config -> securesmtp = 1 ;
238+ if (Mail ) Mail -> securesmtp = 1 ;
239+ }
240+ else if (strcmp (node [i ]-> content , "no" ) == 0 )
241+ {
242+ if (Config ) Config -> securesmtp = 0 ;
243+ if (Mail ) Mail -> securesmtp = 0 ;
244+ }
245+ else
246+ {
247+ return (OS_INVALID );
248+ }
249+ }
209250 /* Prelude support */
210251 else if (strcmp (node [i ]-> element , xml_prelude ) == 0 ) {
211252 if (strcmp (node [i ]-> content , "yes" ) == 0 ) {
@@ -453,17 +494,39 @@ int Read_Global(XML_NODE node, void *configp, void *mailp)
453494 }
454495 os_strdup (node [i ]-> content , Mail -> idsname );
455496 }
497+ } else if (strcmp (node [i ]-> element , xml_smtp_user ) == 0 ) {
498+ if (Mail && (Mail -> authsmtp ))
499+ {
500+ if (Mail -> smtp_user )
501+ {
502+ free (Mail -> smtp_user );
503+ }
504+ os_strdup (node [i ]-> content , Mail -> smtp_user );
505+ }
506+ } else if (strcmp (node [i ]-> element , xml_smtp_pass ) == 0 ) {
507+ if (Mail && (Mail -> authsmtp ))
508+ {
509+ if (Mail -> smtp_pass )
510+ {
511+ free (Mail -> smtp_pass );
512+ }
513+ os_strdup (node [i ]-> content , Mail -> smtp_pass );
514+ }
456515 } else if (strcmp (node [i ]-> element , xml_smtpserver ) == 0 ) {
457516#ifndef WIN32
458517 if (Mail && (Mail -> mn )) {
459518 if (node [i ]-> content [0 ] == '/' ) {
460519 os_strdup (node [i ]-> content , Mail -> smtpserver );
461520 } else {
521+ #ifdef SENDMAIL_CURL
522+ os_strdup (node [i ]-> content , Mail -> smtpserver );
523+ #else
462524 Mail -> smtpserver = OS_GetHost (node [i ]-> content , 5 );
463525 if (!Mail -> smtpserver ) {
464526 merror (INVALID_SMTP , __local_name , node [i ]-> content );
465527 return (OS_INVALID );
466528 }
529+ #endif
467530 }
468531 free (Mail -> smtpserver );
469532 os_strdup (node [i ]-> content , Mail -> smtpserver );
0 commit comments