mail
char helo[MAX_MAIL], mail[MAX_MAIL], rcpt[MAX_MAIL];
goto mail;
mail:
setlog(cp->mail, sizeof cp->mail, cp->ibuf);
if (cp->mail[0] && cp->rcpt[0]) {
cp->addr, cp->mail,
cp->addr, cp->mail, cp->rcpt);
cp->mail, cp->rcpt);
goto mail;
char mail[sizeof(_PATH_MAILDIR) + 1 + NAME_MAX];
(void)snprintf(mail, sizeof(mail), "%s/%s", _PATH_MAILDIR,
setenv("MAIL", mail, 1) == -1) {
if (stat(mail, &st) == 0 && st.st_size != 0)
int mail(struct name *, struct name *, struct name *, struct name *,
mail(to, cc, bcc, smopts, fromaddr, subject);
FILE *mail;
if (!(mail = cron_popen(mailcmd, "w", pw, &mailpid))) {
fprintf(mail, "From: %s (Atrun Service)\n", pw->pw_name);
fprintf(mail, "To: %s\n", mailto);
fprintf(mail, "Subject: Output from \"at\" job\n");
fprintf(mail, "Auto-Submitted: auto-generated\n");
fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s\"\n",
fprintf(mail, "\nproduced the following output:\n\n");
fwrite(buf, nread, 1, mail);
if ((status = cron_pclose(mail, mailpid)) != 0) {
FILE *mail = NULL;
if (!(mail = cron_popen(mailcmd, "w", e->pwd,
fprintf(mail, "From: root (Cron Daemon)\n");
fprintf(mail, "To: %s\n", mailto);
fprintf(mail, "Subject: Cron <%s@%s> %s\n",
fprintf(mail, "Auto-Submitted: auto-generated\n");
fprintf(mail, "X-Cron-Env: <%s>\n",
fprintf(mail, "\n");
fputc(ch, mail);
if (mail)
fputc(ch, mail);
&& mail) {
(void)fclose(mail);
mail = NULL;
if (mail) {
status = cron_pclose(mail, mailpid);
if (mail && status) {
free(job.mail);
job.mail = xstrdup(line + 1);
free(job.mail);
char *mail;
if (job->mail)
user = job->mail;
smtp_sendmail(struct smtp_client *proto, struct smtp_mail *mail)
proto->mail = mail;
if (proto->mail)
if (proto->mail)
if (proto->mail)
proto->mail->from,
proto->mail->dsn_ret ? " RET=" : "",
proto->mail->dsn_ret ? proto->mail->dsn_ret : "",
proto->mail->dsn_envid ? " ENVID=" : "",
proto->mail->dsn_envid ? proto->mail->dsn_envid : "");
proto->mail->from);
if (proto->rcptidx == proto->mail->rcptcount) {
rcpt = &proto->mail->rcpt[proto->rcptidx];
fseek(proto->mail->fp, 0, SEEK_SET);
rcpt = &proto->mail->rcpt[proto->rcptidx++];
for (i = 0, seen = 0; i < proto->mail->rcptcount; i++) {
rcpt = &proto->mail->rcpt[i];
&proto->mail->rcpt[i], line);
if ((len = getline(&ln, &sz, proto->mail->fp)) == -1)
if (ferror(proto->mail->fp)) {
if (feof(proto->mail->fp))
for (i = 0; i < proto->mail->rcptcount; i++)
smtp_client_rcpt_status(proto, &proto->mail->rcpt[i], status);
smtp_done(proto->tag, proto, proto->mail);
struct smtp_mail *mail;
proto->mail = NULL;
smtp_done(proto->tag, proto, proto->mail);
proto->mail = NULL;
memset(&mail, 0, sizeof(mail));
mail.from = pw->pw_name;
mail.from = optarg;
mail.rcpt = calloc(argc, sizeof(*mail.rcpt));
if (mail.rcpt == NULL)
mail.rcpt[i].to = argv[i];
mail.rcptcount = argc;
if ((mail.fp = tmpfile()) == NULL)
if (fwrite(line, 1, len, mail.fp) != len)
if (line[len - 1] != '\n' && fputc('\n', mail.fp) == EOF)
rewind(mail.fp);
static struct smtp_mail mail;
smtp_sendmail(proto, &mail);
smtp_done(void *tag, struct smtp_client *proto, struct smtp_mail *mail)
for (i = 0; i < mail->rcptcount; i++)
if (!mail->rcpt[i].done)