summaryrefslogtreecommitdiff
path: root/pith/send.c
diff options
context:
space:
mode:
Diffstat (limited to 'pith/send.c')
-rw-r--r--pith/send.c71
1 files changed, 55 insertions, 16 deletions
diff --git a/pith/send.c b/pith/send.c
index a0c60439..3cca3365 100644
--- a/pith/send.c
+++ b/pith/send.c
@@ -44,6 +44,7 @@ static char rcsid[] = "$Id: send.c 1204 2009-02-02 19:54:23Z hubert@u.washington
#include "../pith/ablookup.h"
#include "../pith/sort.h"
#include "../pith/smime.h"
+#include "../pith/rules.h"
#include "../c-client/smtp.h"
#include "../c-client/nntp.h"
@@ -53,7 +54,7 @@ static char rcsid[] = "$Id: send.c 1204 2009-02-02 19:54:23Z hubert@u.washington
/* name::type::canedit::writehdr::localcopy::rcptto */
PINEFIELD pf_template[] = {
{"X-Auth-Received", FreeText, 0, 1, 1, 0}, /* N_AUTHRCVD */
- {"From", Address, 0, 1, 1, 0},
+ {"From", Address, 1, 1, 1, 0},
{"Reply-To", Address, 0, 1, 1, 0},
{TONAME, Address, 1, 1, 1, 1},
{CCNAME, Address, 1, 1, 1, 1},
@@ -257,6 +258,13 @@ postponed_stream(MAILSTREAM **streamp, char *mbox, char *type, int checknmsgs)
if(exists & FEX_ISFILE){
context_apply(tmp, p_cntxt, mbox, sizeof(tmp));
+#ifndef _WINDOWS
+ if (!struncmp(tmp, "#md/",4) || !struncmp(tmp, "#mc/", 4)){
+ char tmp2[MAILTMPLEN];
+ maildir_file_path(tmp, tmp2, sizeof(tmp2));
+ strcpy(tmp, tmp2);
+ }
+#endif
if(!(IS_REMOTE(tmp) || is_absolute_path(tmp))){
/*
* The mbox is relative to the home directory.
@@ -1229,7 +1237,7 @@ pine_new_env(ENVELOPE *outgoing, char **fccp, char ***tobufpp, PINEFIELD *custom
*p = *(p+4);
pf->type = pf_template[i].type;
- pf->canedit = pf_template[i].canedit;
+ pf->canedit = (i == N_FROM) ? CAN_EDIT(ps_global) : pf_template[i].canedit;
pf->rcptto = pf_template[i].rcptto;
pf->writehdr = pf_template[i].writehdr;
pf->localcopy = pf_template[i].localcopy;
@@ -1738,9 +1746,9 @@ call_mailer(METAENV *header, struct mail_bodystruct *body, char **alt_smtp_serve
char error_buf[200], *error_mess = NULL, *postcmd;
ADDRESS *a;
ENVELOPE *fake_env = NULL;
- int addr_error_count, we_cancel = 0;
+ int addr_error_count, we_cancel = 0, choice, num_rules = 0, added_rules = -1;
long smtp_opts = 0L;
- char *verbose_file = NULL;
+ char *verbose_file = NULL, **smtp_list;
BODY *bp = NULL;
PINEFIELD *pf;
BODY *origBody = body;
@@ -1893,20 +1901,49 @@ call_mailer(METAENV *header, struct mail_bodystruct *body, char **alt_smtp_serve
* OK, who posts what? We tried an mta_handoff above, but there
* was either none specified or we decided not to use it. So,
* if there's an smtp-server defined anywhere,
+ * First we check for rules and make a list using the rules.
*/
- if(alt_smtp_servers && alt_smtp_servers[0] && alt_smtp_servers[0][0]){
- /*---------- SMTP ----------*/
- dprint((4, "call_mailer: via TCP (%s)\n",
- alt_smtp_servers[0]));
- TIME_STAMP("smtp-open start (tcp)", 1);
- sending_stream = smtp_open(alt_smtp_servers, smtp_opts);
+ if(ps_global->VAR_SMTP_RULES && ps_global->VAR_SMTP_RULES[0]
+ && ps_global->VAR_SMTP_RULES[0][0])
+ while (ps_global->VAR_SMTP_RULES[num_rules]) num_rules++;
+
+ if(num_rules){
+ int i, j;
+
+ added_rules = 0;
+ smtp_list = (char **) fs_get ((num_rules + 1)*sizeof(char*));
+ for (i = 0, j = 0; i < num_rules; i++){
+ RULELIST *rule = get_rulelist_from_code(V_SMTP_RULES,
+ ps_global->rule_list);
+ RULE_S *prule = get_rule(rule, i);
+ if(prule){
+ char *rule_result = process_rule(prule, FOR_COMPOSE, header->env);
+ if(rule_result && *rule_result){
+ smtp_list[j++] = cpystr(rule_result);
+ added_rules++;
+ }
+ }
+ }
+ }
+
+ if (added_rules < 0){
+ smtp_list = (char **) fs_get (sizeof(char*));
+ added_rules = 0;
}
- else if(ps_global->VAR_SMTP_SERVER && ps_global->VAR_SMTP_SERVER[0]
- && ps_global->VAR_SMTP_SERVER[0][0]){
- /*---------- SMTP ----------*/
- dprint((4, "call_mailer: via TCP\n"));
- TIME_STAMP("smtp-open start (tcp)", 1);
- sending_stream = smtp_open(ps_global->VAR_SMTP_SERVER, smtp_opts);
+ smtp_list[added_rules] = NULL;
+
+ choice = smtp_list && smtp_list[0] && smtp_list[0][0] ? 3 :
+ (alt_smtp_servers && alt_smtp_servers[0] && alt_smtp_servers[0][0] ? 2 :
+ (ps_global->VAR_SMTP_SERVER && ps_global->VAR_SMTP_SERVER[0]
+ && ps_global->VAR_SMTP_SERVER[0][0] ? 1 : -1));
+
+ if(choice > 0){
+ /*---------- SMTP ----------*/
+ dprint((4, "call_mailer: via TCP (%s)\n",smtp_list[0]));
+ TIME_STAMP("smtp-open start (tcp)", 1);
+ sending_stream = smtp_open(choice == 3 ? smtp_list
+ : (choice == 2 ? alt_smtp_servers
+ : ps_global->VAR_SMTP_SERVER), smtp_opts);
}
else if((postcmd = smtp_command(ps_global->c_client_error, sizeof(ps_global->c_client_error))) != NULL){
char *cmdlist[2];
@@ -2142,6 +2179,8 @@ call_mailer(METAENV *header, struct mail_bodystruct *body, char **alt_smtp_serve
if(error_mess){
q_status_message(SM_ORDER | SM_DING, 4, 7, error_mess);
dprint((1, "call_mailer ERROR: %s\n", error_mess));
+ if (ps_global->send_immediately)
+ printf("%s\n",error_mess);
}
return(-1);