Skip to content

Commit dc6bbc5

Browse files
committed
Add clearer syslog output when server doesn't support any suitable auth mechanisms
1 parent 3e45943 commit dc6bbc5

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

net.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,23 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
581581
* Check if the user wants plain text login without using
582582
* encryption.
583583
*/
584-
syslog(LOG_INFO, "using SMTP authentication for user %s", a->login);
585-
error = smtp_login(fd, a->login, a->password, &features);
586-
if (error < 0) {
587-
syslog(LOG_ERR, "remote delivery failed:"
588-
" SMTP login failed: %m");
589-
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
590-
error = -1;
591-
goto out;
592-
}
593-
/* SMTP login is not available, so try without */
594-
else if (error > 0) {
595-
syslog(LOG_WARNING, "SMTP login not available. Trying without.");
584+
if (features.auth.cram_md5 || features.auth.login || features.auth.plain) {
585+
syslog(LOG_INFO, "using SMTP authentication for user %s", a->login);
586+
error = smtp_login(fd, a->login, a->password, &features);
587+
if (error < 0) {
588+
syslog(LOG_ERR, "remote delivery failed:"
589+
" SMTP login failed: %m");
590+
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
591+
error = -1;
592+
goto out;
593+
}
594+
/* SMTP login is not available, so try without */
595+
else if (error > 0) {
596+
syslog(LOG_WARNING, "SMTP login not available. Trying without.");
597+
}
598+
} else {
599+
syslog(LOG_ERR, "No supported AUTH mechanisms in common with server."
600+
" Skipping authentication.");
596601
}
597602
}
598603

0 commit comments

Comments
 (0)