char listctrl = 0;
char *verp = NULL;
char *verpfrom;
- char *reply, *smtphelo, *requeuefilename;
+ char *reply, *requeuefilename;
DIR *subddir;
struct dirent *dp;
struct stat st;
strlist stl = tll_init();
- unsigned short smtpport;
struct sigaction sigact;
struct mail mail = { 0 };
struct ml ml;
xasprintf(&archivefilename, "%s/archive/%d", ml.dir, mindex);
}
- if(!relayhost)
- relayhost = ctrlvalue(ml.ctrlfd, "relayhost");
- if(!relayhost)
- relayhost = xstrdup(RELAYHOST);
-
- smtpport = ctrlushort(ml.ctrlfd, "smtpport", 25);
- if ((smtphelo = ctrlvalue(ml.ctrlfd, "smtphelo")) == NULL) {
- smtphelo = hostnamestr();
- }
-
switch(listctrl) {
case '2': /* Moderators */
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
mail.from = bounceaddr;
mail.replyto = NULL;
if(send_mail_many_fd(sockfd, &mail, &ml, subfd, NULL)) {
}
break;
case '3': /* resending earlier failed mails */
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
mail.from = NULL;
mail.replyto = NULL;
if(send_mail_many_fd(sockfd, &mail, &ml, subfd, mailfilename)) {
unlink(subfilename);
break;
case '4': /* send mails to owner */
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
mail.from = bounceaddr;
mail.replyto = NULL;
if(send_mail_many_fd(sockfd, &mail, &ml, subfd, mailfilename)) {
}
if(verp) {
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
if(sockfd > -1) {
if(write_mail_from(sockfd, verpfrom, verp)) {
log_error(LOG_ARGS,
tll_remove_and_free(stl, it, free);
}
if(tll_length(stl) == maxverprecips) {
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
if(verp) {
mail.from = verpfrom;
mail.replyto = NULL;
fclose(f);
}
if(tll_length(stl)) {
- initsmtp(&sockfd, relayhost, smtpport, smtphelo);
+ sockfd = newsmtp(&ml, relayhost);
if(verp) {
mail.from = verpfrom;
mail.replyto = NULL;
}
free(verp);
- free(smtphelo);
if(archive) {
if(!ctrlarchive) {
}
int
-newsmtp(struct ml *ml)
+newsmtp(struct ml *ml, const char *rhost)
{
int sockfd;
- char *relayhost, *smtphelo;
+ char *relayhost = NULL, *smtphelo;
unsigned short smtpport = ctrlushort(ml->ctrlfd, "smtpport", 25);
- relayhost = ctrlvalue(ml->ctrlfd, "relayhost");
+ if (rhost != NULL)
+ relayhost = xstrdup(relayhost);
+ if (relayhost == NULL)
+ relayhost = ctrlvalue(ml->ctrlfd, "relayhost");
if (relayhost == NULL)
relayhost = xstrdup(RELAYHOST);
smtphelo = ctrlvalue(ml->ctrlfd, "smtphelo");
{
int sockfd;
- sockfd = newsmtp(ml);
+ sockfd = newsmtp(ml, NULL);
if (sockfd == -1)
return (false);
if (send_mail(sockfd, mail, ml->fd, ml->ctrlfd, bounce)) {
ml.dir = "list";
ATF_REQUIRE_MSG(ml_open(&ml, false), "impossible to open the mailing list");
atf_utils_create_file("list/control/smtpport", "25678");
- int fd = newsmtp(&ml);
+ int fd = newsmtp(&ml, NULL);
ATF_REQUIRE_MSG(fd == -1, "Socket should not have open");
int smtppipe[2];
ATF_REQUIRE(socketpair(AF_UNIX, SOCK_STREAM, 0, smtppipe) >= 0);
atf_utils_readline(smtppipe[0]);
atf_utils_create_file("list/control/smtphelo", "heloname");
atf_utils_create_file("list/control/relayhost", "127.0.0.1");
- fd = newsmtp(&ml);
+ fd = newsmtp(&ml, NULL);
ATF_REQUIRE_MSG(fd != -1, "Invalid socket");
endsmtp(&fd);
atf_utils_wait(p, 0, "EHLO heloname\r\nQUIT\r\n", "");