Add from to smtp action.
Nicholas Marriott
16 years ago
|
0 |
10 January 2008
|
|
1 |
|
|
2 |
* Added "from" to smtp action to specify envelope from. Requested by Marco
|
|
3 |
Lopes.
|
|
4 |
|
0 | 5 |
07 January 2008
|
1 | 6 |
|
2 | 7 |
* Use <>s around envelope addresses when using SMTP. Reported by Marco Lopes.
|
53 | 53 |
- change setuid to seteuid
|
54 | 54 |
- document cache commands in man page
|
55 | 55 |
- document command-user
|
|
56 |
- document from on smtp
|
73 | 73 |
enum deliver_smtp_state state;
|
74 | 74 |
size_t len, llen;
|
75 | 75 |
|
|
76 |
from = to = NULL;
|
|
77 |
|
76 | 78 |
io = connectproxy(&data->server,
|
77 | 79 |
conf.verify_certs, conf.proxy, IO_CRLF, conf.timeout, &cause);
|
78 | 80 |
if (io == NULL) {
|
|
83 | 85 |
if (conf.debug > 3 && !conf.syslog)
|
84 | 86 |
io->dup_fd = STDOUT_FILENO;
|
85 | 87 |
|
86 | |
xasprintf(&from, "%s@%s", conf.info.user, conf.info.host);
|
|
88 |
xasprintf(&ptr, "%s@%s", conf.info.user, conf.info.host);
|
87 | 89 |
if (data->to.str == NULL)
|
88 | |
to = xstrdup(from);
|
|
90 |
to = xstrdup(ptr);
|
89 | 91 |
else {
|
90 | 92 |
to = replacestr(&data->to, m->tags, m, &m->rml);
|
91 | 93 |
if (to == NULL || *to == '\0') {
|
|
93 | 95 |
goto error;
|
94 | 96 |
}
|
95 | 97 |
}
|
|
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);
|
96 | 108 |
|
97 | 109 |
llen = IO_LINESIZE;
|
98 | 110 |
lbuf = xmalloc(llen);
|
71 | 71 |
struct deliver_smtp_data {
|
72 | 72 |
struct server server;
|
73 | 73 |
struct replstr to;
|
|
74 |
struct replstr from;
|
74 | 75 |
};
|
75 | 76 |
|
76 | 77 |
/* Deliver mbox data. */
|
99 | 99 |
{ "file-umask", TOKFILEUMASK },
|
100 | 100 |
{ "flock", TOKFLOCK },
|
101 | 101 |
{ "folder", TOKFOLDER },
|
|
102 |
{ "from", TOKFROM },
|
102 | 103 |
{ "from-headers", TOKFROMHEADERS },
|
103 | 104 |
{ "g", TOKGIGABYTES },
|
104 | 105 |
{ "gb", TOKGIGABYTES },
|
121 | 121 |
|
122 | 122 |
%token TOKALL TOKACCOUNT TOKSERVER TOKPORT TOKUSER TOKPASS TOKACTION
|
123 | 123 |
%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
|
125 | 125 |
%token TOKMAXSIZE TOKDELTOOBIG TOKLOCKTYPES TOKDEFUSER TOKDOMAIN TOKDOMAINS
|
126 | 126 |
%token TOKHEADER TOKFROMHEADERS TOKUSERS TOKMATCHED TOKUNMATCHED TOKNOT
|
127 | 127 |
%token TOKIMAP TOKIMAPS TOKDISABLED TOKFOLDER TOKPROXY TOKALLOWMANY TOKDROP
|
|
210 | 210 |
%type <re> casere retre
|
211 | 211 |
%type <rule> perform
|
212 | 212 |
%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
|
214 | 214 |
%type <strings> stringslist pathslist
|
215 | 215 |
%type <strings> domains headers maildirs mboxes groups
|
216 | 216 |
%type <users> users userslist
|
|
1144 | 1144 |
$$ = $2;
|
1145 | 1145 |
}
|
1146 | 1146 |
|
|
1147 |
/** FROM: <string> (char *) */
|
|
1148 |
from: /* empty */
|
|
1149 |
{
|
|
1150 |
$$ = NULL;
|
|
1151 |
}
|
|
1152 |
| TOKFROM strv
|
|
1153 |
/** [$2: strv (char *)] */
|
|
1154 |
{
|
|
1155 |
$$ = $2;
|
|
1156 |
}
|
|
1157 |
|
1147 | 1158 |
/** COMPRESS: <flag> (int) */
|
1148 | 1159 |
compress: TOKCOMPRESS
|
1149 | 1160 |
{
|
|
1268 | 1279 |
data->path.str = $2;
|
1269 | 1280 |
data->compress = $3;
|
1270 | 1281 |
}
|
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 *)] */
|
1273 | 1285 |
{
|
1274 | 1286 |
struct deliver_smtp_data *data;
|
1275 | 1287 |
|
|
1285 | 1297 |
else
|
1286 | 1298 |
data->server.port = xstrdup("smtp");
|
1287 | 1299 |
data->server.ai = NULL;
|
1288 | |
data->to.str = $3;
|
|
1300 |
data->from.str = $3;
|
|
1301 |
data->to.str = $4;
|
1289 | 1302 |
}
|
1290 | 1303 |
| TOKSTDOUT
|
1291 | 1304 |
{
|