comparison mail.c @ 7:4a0de889bcec

Grow buffer; stop including Bcc header
author Adam Chlipala <adam@chlipala.net>
date Thu, 04 Feb 2016 12:49:00 -0500
parents f96ca37be746
children fe6049d23ce5
comparison
equal deleted inserted replaced
6:f96ca37be746 7:4a0de889bcec
141 uw_context ctx; 141 uw_context ctx;
142 uw_Mail_headers h; 142 uw_Mail_headers h;
143 uw_Basis_string body, xbody; 143 uw_Basis_string body, xbody;
144 } job; 144 } job;
145 145
146 #define BUFLEN 1024 146 #define BUFLEN (1024*1024)
147 147
148 static int smtp_read(uw_context ctx, int sock, char *buf, ssize_t *pos) { 148 static int smtp_read(uw_context ctx, int sock, char *buf, ssize_t *pos) {
149 char *s; 149 char *s;
150 150
151 while (1) { 151 while (1) {
185 *pos += recvd; 185 *pos += recvd;
186 } 186 }
187 } 187 }
188 188
189 static int really_string(int sock, const char *s) { 189 static int really_string(int sock, const char *s) {
190 fprintf(stderr, "MAIL: %s\n", s);
190 return uw_really_send(sock, s, strlen(s)); 191 return uw_really_send(sock, s, strlen(s));
191 } 192 }
192 193
193 static int sendAddrs(const char *kind, uw_context ctx, int sock, char *s, char *buf, ssize_t *pos) { 194 static int sendAddrs(const char *kind, uw_context ctx, int sock, char *s, char *buf, ssize_t *pos) {
194 char *p; 195 char *p;
352 uw_set_error_message(j->ctx, "Error sending Cc"); 353 uw_set_error_message(j->ctx, "Error sending Cc");
353 return; 354 return;
354 } 355 }
355 } 356 }
356 357
357 if (j->h->bcc) {
358 snprintf(out, sizeof(out), "Bcc: %s\r\n", j->h->bcc);
359 out[sizeof(out)-1] = 0;
360
361 if (really_string(sock, out) < 0) {
362 close(sock);
363 uw_set_error_message(j->ctx, "Error sending Bcc");
364 return;
365 }
366 }
367
368 if ((s = uw_get_global(j->ctx, "extra_mail_headers"))) { 358 if ((s = uw_get_global(j->ctx, "extra_mail_headers"))) {
369 if (really_string(sock, s) < 0) { 359 if (really_string(sock, s) < 0) {
370 close(sock); 360 close(sock);
371 uw_set_error_message(j->ctx, "Error sending extra headers"); 361 uw_set_error_message(j->ctx, "Error sending extra headers");
372 return; 362 return;