- struct hlist* p;
-
- fd = open_mailbox(where, last_try);
- if (fd < 0)
- goto end;
- off = lseek(fd, 0, SEEK_END);
- if (off < 0)
- goto end;
- LIST_FOREACH(p, em.headers) {
- len = strlen(p->name);
- written = write(fd, p->name, len);
- if (written < len) {
- ftruncate(fd, off);
- goto end;
- }
-
- written = write(fd, ": ", 2);
- if (written < 2) {
- ftruncate(fd, off);
- goto end;
- }
-
- len = strlen(p->value);
- written = write(fd, p->value, len);
- if (written < len) {
- ftruncate(fd, off);
- goto end;
- }
-
- written = write(fd, "\n", 1);
- if (written < len) {
- ftruncate(fd, off);
- goto end;
- }
- }
- written = write(fd, "\n", 1);
- if (written < 1) {
- ftruncate(fd, off);
- goto end;
- }
-
- written = write(fd, em.body, em.body_len);
- if (written < em.body_len) {
- ftruncate(fd, off);
- goto end;
- }
-
- ok = 1;
- close_mailbox(fd, where, last_try);
-