/*
+ * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
* Copyright (c) 2008 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
return (0);
} else if (res == -2) {
/*
- * If the return code is -2, then then the login attempt failed,
+ * If the return code is -2, then then the login attempt failed,
* do not try other login mechanisms
*/
return (1);
host->host, host->addr, c, neterr); \
snprintf(errmsg, sizeof(errmsg), "%s [%s] did not like our %s:\n%s", \
host->host, host->addr, c, neterr); \
- return (-1); \
+ error = -1; \
+ goto out; \
} else if (res != exp) { \
syslog(LOG_NOTICE, "remote delivery deferred: %s [%s] failed after %s: %s", \
host->host, host->addr, c, neterr); \
- return (1); \
+ error = 1; \
+ goto out; \
}
/* Check first reply from remote host */
syslog(LOG_ERR, "remote delivery failed:"
" SMTP login failed: %m");
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
- return (-1);
+ error = -1;
+ goto out;
}
/* SMTP login is not available, so try without */
else if (error > 0) {
int port;
int error = 1, smarthost = 0;
- host = strrchr(it->addr, '@');
- /* Should not happen */
- if (host == NULL) {
- snprintf(errmsg, sizeof(errmsg), "Internal error: badly formed address %s",
- it->addr);
- return(-1);
- } else {
- /* Step over the @ */
- host++;
- }
-
port = SMTP_PORT;
/* Smarthost support? */
port = config.port;
syslog(LOG_INFO, "using smarthost (%s:%i)", host, port);
smarthost = 1;
+ } else {
+ host = strrchr(it->addr, '@');
+ /* Should not happen */
+ if (host == NULL) {
+ snprintf(errmsg, sizeof(errmsg), "Internal error: badly formed address %s",
+ it->addr);
+ return(-1);
+ } else {
+ /* Step over the @ */
+ host++;
+ }
}
error = dns_get_mx_list(host, port, &hosts, smarthost);
if (error) {
- syslog(LOG_NOTICE, "remote delivery %s: DNS failure (%s)",
+ snprintf(errmsg, sizeof(errmsg), "DNS lookup failure: host %s not found", host);
+ syslog(LOG_NOTICE, "remote delivery %s: DNS lookup failure: host %s not found",
error < 0 ? "failed" : "deferred",
host);
return (error);