comparison mail.c @ 2:bf58106560ba

Carriage returns at ends of messages; more .hgignore for Autotools
author Adam Chlipala <adam@chlipala.net>
date Sat, 27 Dec 2014 07:17:50 -0500
parents 33bf7ee17644
children 0420bfe96dda
comparison
equal deleted inserted replaced
1:db4d025f7bd3 2:bf58106560ba
198 return 0; 198 return 0;
199 199
200 for (p = strchr(s, ','); p; p = strchr(p+1, ',')) { 200 for (p = strchr(s, ','); p; p = strchr(p+1, ',')) {
201 *p = 0; 201 *p = 0;
202 202
203 snprintf(out, sizeof(out), "RCPT TO:%s\n", s); 203 snprintf(out, sizeof(out), "RCPT TO:%s\r\n", s);
204 out[sizeof(out)-1] = 0; 204 out[sizeof(out)-1] = 0;
205 *p = ','; 205 *p = ',';
206 206
207 if (really_string(sock, out) < 0) { 207 if (really_string(sock, out) < 0) {
208 close(sock); 208 close(sock);
216 return 1; 216 return 1;
217 } 217 }
218 } 218 }
219 219
220 if (*s) { 220 if (*s) {
221 snprintf(out, sizeof(out), "RCPT TO:%s\n", s); 221 snprintf(out, sizeof(out), "RCPT TO:%s\r\n", s);
222 out[sizeof(out)-1] = 0; 222 out[sizeof(out)-1] = 0;
223 223
224 if (really_string(sock, out) < 0) { 224 if (really_string(sock, out) < 0) {
225 close(sock); 225 close(sock);
226 uw_set_error_message(ctx, "Error sending RCPT TO for %s", kind); 226 uw_set_error_message(ctx, "Error sending RCPT TO for %s", kind);
265 close(sock); 265 close(sock);
266 uw_set_error_message(j->ctx, "Mail server doesn't greet with code 220."); 266 uw_set_error_message(j->ctx, "Mail server doesn't greet with code 220.");
267 return; 267 return;
268 } 268 }
269 269
270 if (really_string(sock, "HELO localhost\n") < 0) { 270 if (really_string(sock, "HELO localhost\r\n") < 0) {
271 close(sock); 271 close(sock);
272 uw_set_error_message(j->ctx, "Error sending HELO"); 272 uw_set_error_message(j->ctx, "Error sending HELO");
273 return; 273 return;
274 } 274 }
275 275
277 close(sock); 277 close(sock);
278 uw_set_error_message(j->ctx, "Mail server doesn't respond to HELO with code 250."); 278 uw_set_error_message(j->ctx, "Mail server doesn't respond to HELO with code 250.");
279 return; 279 return;
280 } 280 }
281 281
282 snprintf(out, sizeof(out), "MAIL FROM:%s\n", j->h->from); 282 snprintf(out, sizeof(out), "MAIL FROM:%s\r\n", j->h->from);
283 out[sizeof(out)-1] = 0; 283 out[sizeof(out)-1] = 0;
284 284
285 if (really_string(sock, out) < 0) { 285 if (really_string(sock, out) < 0) {
286 close(sock); 286 close(sock);
287 uw_set_error_message(j->ctx, "Error sending MAIL FROM"); 287 uw_set_error_message(j->ctx, "Error sending MAIL FROM");
296 296
297 if (sendAddrs("To", j->ctx, sock, j->h->to, buf, &pos)) return; 297 if (sendAddrs("To", j->ctx, sock, j->h->to, buf, &pos)) return;
298 if (sendAddrs("Cc", j->ctx, sock, j->h->cc, buf, &pos)) return; 298 if (sendAddrs("Cc", j->ctx, sock, j->h->cc, buf, &pos)) return;
299 if (sendAddrs("Bcc", j->ctx, sock, j->h->bcc, buf, &pos)) return; 299 if (sendAddrs("Bcc", j->ctx, sock, j->h->bcc, buf, &pos)) return;
300 300
301 if (really_string(sock, "DATA\n") < 0) { 301 if (really_string(sock, "DATA\r\n") < 0) {
302 close(sock); 302 close(sock);
303 uw_set_error_message(j->ctx, "Error sending DATA"); 303 uw_set_error_message(j->ctx, "Error sending DATA");
304 return; 304 return;
305 } 305 }
306 306
456 close(sock); 456 close(sock);
457 uw_set_error_message(j->ctx, "Mail server doesn't respond to end of message with code 250."); 457 uw_set_error_message(j->ctx, "Mail server doesn't respond to end of message with code 250.");
458 return; 458 return;
459 } 459 }
460 460
461 if (really_string(sock, "QUIT\n") < 0) { 461 if (really_string(sock, "QUIT\r\n") < 0) {
462 close(sock); 462 close(sock);
463 uw_set_error_message(j->ctx, "Error sending QUIT"); 463 uw_set_error_message(j->ctx, "Error sending QUIT");
464 return; 464 return;
465 } 465 }
466 466