Codebase list fdm / 4db830e
Add from to smtp action. Nicholas Marriott 16 years ago
6 changed file(s) with 40 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
0 10 January 2008
1
2 * Added "from" to smtp action to specify envelope from. Requested by Marco
3 Lopes.
4
05 07 January 2008
16
27 * Use <>s around envelope addresses when using SMTP. Reported by Marco Lopes.
5353 - change setuid to seteuid
5454 - document cache commands in man page
5555 - document command-user
56 - document from on smtp
7373 enum deliver_smtp_state state;
7474 size_t len, llen;
7575
76 from = to = NULL;
77
7678 io = connectproxy(&data->server,
7779 conf.verify_certs, conf.proxy, IO_CRLF, conf.timeout, &cause);
7880 if (io == NULL) {
8385 if (conf.debug > 3 && !conf.syslog)
8486 io->dup_fd = STDOUT_FILENO;
8587
86 xasprintf(&from, "%s@%s", conf.info.user, conf.info.host);
88 xasprintf(&ptr, "%s@%s", conf.info.user, conf.info.host);
8789 if (data->to.str == NULL)
88 to = xstrdup(from);
90 to = xstrdup(ptr);
8991 else {
9092 to = replacestr(&data->to, m->tags, m, &m->rml);
9193 if (to == NULL || *to == '\0') {
9395 goto error;
9496 }
9597 }
98 if (data->from.str == NULL)
99 from = xstrdup(ptr);
100 else {
101 from = replacestr(&data->from, m->tags, m, &m->rml);
102 if (from == NULL || *from == '\0') {
103 log_warnx("%s: empty from", a->name);
104 goto error;
105 }
106 }
107 xfree(ptr);
96108
97109 llen = IO_LINESIZE;
98110 lbuf = xmalloc(llen);
7171 struct deliver_smtp_data {
7272 struct server server;
7373 struct replstr to;
74 struct replstr from;
7475 };
7576
7677 /* Deliver mbox data. */
9999 { "file-umask", TOKFILEUMASK },
100100 { "flock", TOKFLOCK },
101101 { "folder", TOKFOLDER },
102 { "from", TOKFROM },
102103 { "from-headers", TOKFROMHEADERS },
103104 { "g", TOKGIGABYTES },
104105 { "gb", TOKGIGABYTES },
121121
122122 %token TOKALL TOKACCOUNT TOKSERVER TOKPORT TOKUSER TOKPASS TOKACTION
123123 %token TOKSET TOKACCOUNTS TOKMATCH TOKIN TOKCONTINUE TOKSTDIN TOKPOP3 TOKPOP3S
124 %token TOKNONE TOKCASE TOKAND TOKOR TOKTO TOKACTIONS TOKHEADERS TOKBODY
124 %token TOKNONE TOKCASE TOKAND TOKOR TOKFROM TOKTO TOKACTIONS TOKHEADERS TOKBODY
125125 %token TOKMAXSIZE TOKDELTOOBIG TOKLOCKTYPES TOKDEFUSER TOKDOMAIN TOKDOMAINS
126126 %token TOKHEADER TOKFROMHEADERS TOKUSERS TOKMATCHED TOKUNMATCHED TOKNOT
127127 %token TOKIMAP TOKIMAPS TOKDISABLED TOKFOLDER TOKPROXY TOKALLOWMANY TOKDROP
210210 %type <re> casere retre
211211 %type <rule> perform
212212 %type <server> server
213 %type <string> port to folder xstrv strv replstrv replpathv val optval
213 %type <string> port to from folder xstrv strv replstrv replpathv val optval
214214 %type <strings> stringslist pathslist
215215 %type <strings> domains headers maildirs mboxes groups
216216 %type <users> users userslist
11441144 $$ = $2;
11451145 }
11461146
1147 /** FROM: <string> (char *) */
1148 from: /* empty */
1149 {
1150 $$ = NULL;
1151 }
1152 | TOKFROM strv
1153 /** [$2: strv (char *)] */
1154 {
1155 $$ = $2;
1156 }
1157
11471158 /** COMPRESS: <flag> (int) */
11481159 compress: TOKCOMPRESS
11491160 {
12681279 data->path.str = $2;
12691280 data->compress = $3;
12701281 }
1271 | TOKSMTP server to
1272 /** [$2: server (struct { ... } server)] [$3: to (char *)] */
1282 | TOKSMTP server from to
1283 /** [$2: server (struct { ... } server)] [$3: from (char *)] */
1284 /** [$4: to (char *)] */
12731285 {
12741286 struct deliver_smtp_data *data;
12751287
12851297 else
12861298 data->server.port = xstrdup("smtp");
12871299 data->server.ai = NULL;
1288 data->to.str = $3;
1300 data->from.str = $3;
1301 data->to.str = $4;
12891302 }
12901303 | TOKSTDOUT
12911304 {