}
close(*sockfd);
-
*sockfd = -1;
return retval;
case '1': /* A single mail is to be sent */
case '6':
initsmtp(&sockfd, relay, smtpport);
- sendres = send_mail(sockfd, bounceaddr, to_addr, replyto,
+ if(send_mail(sockfd, bounceaddr, to_addr, replyto,
mailmap, st.st_size, listdir, NULL,
- hdrs, hdrslen, body, bodylen);
- endsmtp(&sockfd);
- if(sendres) {
+ hdrs, hdrslen, body, bodylen)) {
+ close(sockfd);
+ sockfd = -1;
/* error, so keep it in the queue */
deletewhensent = 0;
/* dump data we want when resending first check
}
close(tmpfd);
}
+ } else {
+ endsmtp(&sockfd);
}
break;
case '2': /* Moderators */
if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
st.st_size, subfd, NULL, NULL, NULL,
listdir, NULL, hdrs, hdrslen,
- body, bodylen))
+ body, bodylen)) {
close(sockfd);
- else
+ sockfd = -1;
+ } else {
endsmtp(&sockfd);
+ }
break;
case '3': /* resending earlier failed mails */
initsmtp(&sockfd, relay, smtpport);
if(send_mail_many_fd(sockfd, NULL, NULL, mailmap, st.st_size,
subfd, listaddr, listdelim, mailfilename,
listdir, mlmmjbounce, hdrs, hdrslen,
- body, bodylen))
+ body, bodylen)) {
close(sockfd);
- else
+ sockfd = -1;
+ } else {
endsmtp(&sockfd);
+ }
unlink(subfilename);
break;
case '4': /* send mails to owner */
if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
st.st_size, subfd, listaddr, listdelim,
mailfilename, listdir, mlmmjbounce,
- hdrs, hdrslen, body, bodylen))
+ hdrs, hdrslen, body, bodylen)) {
close(sockfd);
- else
+ sockfd = -1;
+ } else {
endsmtp(&sockfd);
+ }
break;
case '5': /* bounceprobe - handle relayhost local users bouncing*/
initsmtp(&sockfd, relay, smtpport);
- sendres = send_mail(sockfd, bounceaddr, to_addr, replyto,
+ if(send_mail(sockfd, bounceaddr, to_addr, replyto,
mailmap, st.st_size, listdir, NULL,
- hdrs, hdrslen, body, bodylen);
- endsmtp(&sockfd);
- if(sendres) {
+ hdrs, hdrslen, body, bodylen)) {
+ close(sockfd);
+ sockfd = -1;
/* error, so remove the probefile */
tmpstr = mystrdup(to_addr);
a = strchr(tmpstr, '@');
unlink(probefile);
myfree(probefile);
myfree(tmpstr);
+ } else {
+ endsmtp(&sockfd);
}
break;
case '7':
verp = NULL;
}
}
+ /* We can't be in SMTP DATA state or anything like
+ * that, so should be able to safely QUIT. */
endsmtp(&sockfd);
}
hdrs, hdrslen,
body, bodylen);
}
- endsmtp(&sockfd);
+ if (sendres) {
+ close(sockfd);
+ sockfd = -1;
+ } else {
+ endsmtp(&sockfd);
+ }
for(i = 0; i < stl.count; i++)
myfree(stl.strs[i]);
stl.count = 0;
mlmmjbounce, hdrs, hdrslen,
body, bodylen);
}
- endsmtp(&sockfd);
+ if (sendres) {
+ close(sockfd);
+ sockfd = -1;
+ } else {
+ endsmtp(&sockfd);
+ }
for(i = 0; i < stl.count; i++)
myfree(stl.strs[i]);
stl.count = 0;
}
-
- if (sendres) {
- /* If send_mail_many() failed we close the
- * connection to the mail server in a brutal
- * manner, because we could be in any state
- * (DATA for instance). */
- close(sockfd);
- } else {
- endsmtp(&sockfd);
- }
myfree(stl.strs);
myfree(verpfrom);
closedir(subddir);
myfree(hdrs);
myfree(body);
myfree(mlmmjbounce);
- close(sockfd);
munmap(mailmap, st.st_size);
close(mailfd);
myfree(verp);