Qmail patch for sending auth tls mail to MTA more recent.
I use qmail for sending and receiving mail for my own family.
These periods lot of ( Italian ? ) ISP block tcp port 25 in exit, trying to stop, or at least minimize spam from various windows virus so I found a very good solution to create a free account on smtp2go that offer a free 1000 mails/month without adding anything to your original mail, and don't use port 25 for sending out mails.
You only need to use auth to "login" to smtp for sending the mail.
Recently they changed something in their servers that broke up my setup.
Basically, qmail, when sending out mails to a server that offer TLS by changing the preferred method from :
250-AUTH CRAM-MD5 LOGIN PLAIN to 250-AUTH SCRAM-SHA-1 SCRAM-SHA-256 CRAM-MD5 PLAIN LOGINbreaking the sending of the mail.In the qmail-remote.c infact there is the smtp_auth function wich read the AUTH line, and search for the very first word after AUTH.
If it is "C" ( for CRAM ), "P" for PLAIN or "L" for LOGIN then qmail would use the correct auth
Being that in this very case ( but there could be more ) the first method offered starts with "S" ( SCRAM ), in qmail_remote get called the: err_authprot(), a line is added in the log
If it is "C" ( for CRAM ), "P" for PLAIN or "L" for LOGIN then qmail would use the correct auth
Being that in this very case ( but there could be more ) the first method offered starts with "S" ( SCRAM ), in qmail_remote get called the: err_authprot(), a line is added in the log
delivery 1: success: no_supported_AUTH_method_found,_continuing_without_authentication./
and mail get sent without authorization ( which ends in mail not being accepted ). I wrote a patch that read the whole AUTH line and search for patterns ( PLAIN, LOGIN,CRAM ) inside, wherever they are and use the first know method ( if any ).
If you are interessed here is the modification to smtp_auth() ( in qmail-remote.c):
--- qmail-remote.c.orig 2026-02-27 08:07:14.238102761 +0100
+++ qmail-remote.c 2026-02-27 08:06:56.307780711 +0100
@@ -694,21 +694,29 @@
{
int i, j;
for (i = 0; i + 8 < smtptext.len; i += str_chr(smtptext.s+i,'\n')+1)
- if (!str_diffn(smtptext.s+i+4,"AUTH",4)) {
- if (j = str_chr(smtptext.s+i+8,'C') > 0)
- if (case_starts(smtptext.s+i+8+j,"CRAM"))
+ if (!str_diffn(smtptext.s+i+4,"AUTH",4)) {
+ int found = 0;
+ char *p = smtptext.s+i+8; /* points to first word after "AUTH " */
+ while (*p && *p != '\n') {
+ /* skip leading spaces */
+ while (*p == ' ') p++;
+ if (*p == '\n' || *p == '\0') break;
+ if (case_starts(p,"CRAM")) {
if (mailfrom_cram() >= 0) return;
-
- if (j = str_chr(smtptext.s+i+8,'P') > 0)
- if (case_starts(smtptext.s+i+8+j,"PLAIN"))
+ found = 1; break;
+ }
+ if (case_starts(p,"PLAIN")) {
if (mailfrom_plain() >= 0) return;
-
- if (j = str_chr(smtptext.s+i+8,'L') > 0)
- if (case_starts(smtptext.s+i+8+j,"LOGIN"))
+ found = 1; break;
+ }
+ if (case_starts(p,"LOGIN")) {
if (mailfrom_login() >= 0) return;
-
- err_authprot();
- mailfrom();
+ found = 1; break;
+ }
+ /* advance to next word */
+ while (*p && *p != ' ' && *p != '\n') p++;
+ }
+ if (!found) { err_authprot(); mailfrom(); }
}
}
Hope this could help someone.
Pierluigi
Commenti
Posta un commento