Skip to content

Commit 46e12ad

Browse files
committed
Add clearer syslog output when server doesn't support any suitable auth mechanisms
1 parent b0caecf commit 46e12ad

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

net.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -606,16 +606,21 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
606606
* Check if the user wants plain text login without using
607607
* encryption.
608608
*/
609-
syslog(LOG_INFO, "using SMTP authentication for user %s", a->login);
610-
error = smtp_auth(fd, a->login, a->password, &features);
611-
if (error < 0) {
612-
snprintf(errmsg, sizeof(errmsg), "SMTP auth to %s failed", host->host);
613-
error = -1;
614-
goto out;
615-
}
616-
/* SMTP auth is not available, so try without */
617-
else if (error > 0) {
618-
syslog(LOG_WARNING, "SMTP auth not available. Trying without.");
609+
if (features.auth.cram_md5 || features.auth.login || features.auth.plain) {
610+
syslog(LOG_INFO, "using SMTP authentication for user %s", a->login);
611+
error = smtp_auth(fd, a->login, a->password, &features);
612+
if (error < 0) {
613+
snprintf(errmsg, sizeof(errmsg), "SMTP auth to %s failed", host->host);
614+
error = -1;
615+
goto out;
616+
}
617+
/* SMTP login is not available, so try without */
618+
else if (error > 0) {
619+
syslog(LOG_WARNING, "SMTP login not available. Trying without.");
620+
}
621+
} else {
622+
syslog(LOG_ERR, "No supported AUTH mechanisms in common with server."
623+
" Skipping authentication.");
619624
}
620625
}
621626

0 commit comments

Comments
 (0)