Observe the 'preferred sender email' and 'preferred sender name' preferences when...
authorArt Cancro <ajc@uncensored.citadel.org>
Sun, 25 Aug 2013 18:56:50 +0000 (14:56 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Sun, 25 Aug 2013 18:56:50 +0000 (14:56 -0400)
citadel/modules/smtp/serv_smtp.c
citadel/modules/smtp/smtp_util.h

index 813d303a482feeecf4fa1664dfc5e8b1ecbb4e8c..be6347466270576c957d1610d8c29e1d3b5a961c 100644 (file)
  * The VRFY and EXPN commands have been removed from this implementation
  * because nobody uses these commands anymore, except for spammers.
  *
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2013 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"
@@ -147,6 +147,8 @@ void smtp_greeting(int is_msa)
        sSMTP->from = NewStrBufPlain(NULL, SIZ);
        sSMTP->recipients = NewStrBufPlain(NULL, SIZ);
        sSMTP->OneRcpt = NewStrBufPlain(NULL, SIZ);
+       sSMTP->preferred_sender_email = NULL;
+       sSMTP->preferred_sender_name = NULL;
 
        /* If this config option is set, reject connections from problem
         * addresses immediately instead of after they execute a RCPT
@@ -336,6 +338,7 @@ void smtp_webcit_preferences_hack_backend(long msgnum, void *userdata) {
 void smtp_webcit_preferences_hack(void) {
        char config_roomname[ROOMNAMELEN];
        char *webcit_conf = NULL;
+       citsmtp *sSMTP = SMTP;
 
        snprintf(config_roomname, sizeof config_roomname, "%010ld.%s", CC->user.usernum, USERCONFIGROOM);
        if (CtdlGetRoom(&CC->room, config_roomname) != 0) {
@@ -352,10 +355,24 @@ void smtp_webcit_preferences_hack(void) {
                return;
        }
 
-       /* FIXME : now do something with this data */
+       /* Parse the webcit configuration and attempt to do something useful with it */
+       char *str = webcit_conf;
+       char *saveptr = str;
+       char *this_line = NULL;
+       while (this_line = strtok_r(str, "\n", &saveptr), this_line != NULL) {
+               str = NULL;
+               if (!strncasecmp(this_line, "defaultfrom|", 12)) {
+                       sSMTP->preferred_sender_email = NewStrBufPlain(&this_line[12], -1);
+               }
+               if (!strncasecmp(this_line, "defaultname|", 12)) {
+                       sSMTP->preferred_sender_name = NewStrBufPlain(&this_line[12], -1);
+               }
+               if ((!strncasecmp(this_line, "defaultname|", 12)) && (sSMTP->preferred_sender_name == NULL)) {
+                       sSMTP->preferred_sender_name = NewStrBufPlain(&this_line[12], -1);
+               }
 
+       }
        free(webcit_conf);
-       abort();
 }
 
 
@@ -444,7 +461,7 @@ void smtp_try_plain(long offset, long Flags)
 
        if (result == login_ok) {
                if (CtdlTryPassword(pass, len) == pass_ok) {
-////                   smtp_webcit_preferences_hack();
+                       smtp_webcit_preferences_hack();
                        smtp_auth_greeting(offset, Flags);
                        return;
                }
@@ -843,14 +860,23 @@ void smtp_data(long offset, long flags)
                if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']);
                if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']);
                if (msg->cm_fields['O'] != NULL) free(msg->cm_fields['O']);
-               msg->cm_fields['A'] = strdup(CCC->user.fullname);
                msg->cm_fields['N'] = strdup(config.c_nodename);
                msg->cm_fields['H'] = strdup(config.c_humannode);
                msg->cm_fields['O'] = strdup(MAILROOM);
 
+               msg->cm_fields['A'] =
+                       ((sSMTP->preferred_sender_name != NULL)
+                       ? strdup(ChrPtr(sSMTP->preferred_sender_name)) 
+                       : strdup(CCC->user.fullname)
+               );
+
                if (!validemail) {
                        if (msg->cm_fields['F'] != NULL) free(msg->cm_fields['F']);
-                       msg->cm_fields['F'] = strdup(CCC->cs_inet_email);
+                       msg->cm_fields['F'] = 
+                               ((sSMTP->preferred_sender_email != NULL)
+                               ? strdup(ChrPtr(sSMTP->preferred_sender_email)) 
+                               : strdup(CCC->cs_inet_email)
+                       );
                }
        }
 
@@ -1056,6 +1082,8 @@ void smtp_cleanup_function(void)
        FreeStrBuf(&sSMTP->from);
        FreeStrBuf(&sSMTP->recipients);
        FreeStrBuf(&sSMTP->OneRcpt);
+       FreeStrBuf(&sSMTP->preferred_sender_email);
+       FreeStrBuf(&sSMTP->preferred_sender_name);
 
        free(sSMTP);
 }
index 1da497de0b3c4f41eb69b1cc0ace38a9d92c7a98..7666a34dfc3980abe56ca9ce833867faaf493c80 100644 (file)
  * The VRFY and EXPN commands have been removed from this implementation
  * because nobody uses these commands anymore, except for spammers.
  *
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2013 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  
- *  
- *  
  */
 
 const char *smtp_get_Recipients(void);
@@ -52,7 +47,9 @@ typedef struct _citsmtp {             /* Information about the current session */
        int is_lmtp;
        int is_unfiltered;
        int is_msa;
-}citsmtp;
+       StrBuf *preferred_sender_email;
+       StrBuf *preferred_sender_name;
+} citsmtp;
 
 #define SMTP           ((citsmtp *)CC->session_specific_data)