Home › Forums › The libraries hosted on the site › EMailSender send email with attachments › help please – smtp error: 503 Bad sequence of commands
Tagged: SASL Authentication, SMTP
- This topic has 17 replies, 1 voice, and was last updated 4 years, 4 months ago by
Renzo Mischianti.
-
AuthorPosts
-
-
21 December 2020 at 19:10 #9013
matthias
thanks for the help in advance !!!
where is the problem here?
why is the void setPublicIpDescriptor(const char *publicIpDescriptor = “mymailde”); part not taken?
Where does this need to be placed in the code?18:58:11.100 -> Connection: ESTABLISHED
18:58:11.100 -> Got IP address: 192.168.1.131
18:58:11.100 -> ONLY ONE RECIPIENTInsecure client:0
18:58:11.199 -> MFLN supported: yes
18:58:12.628 -> 220 kundenserver.de (mreue010) Nemesis ESMTP Service ready
18:58:12.628 -> HELO mischianti:
18:58:12.761 -> 503 Bad sequence of commands
18:58:12.761 -> Sending status:
18:58:12.761 -> 0
18:58:12.761 -> 250
18:58:12.761 -> Identification error (503 Bad sequence of commands )/*
* EMailSender library for Arduino, esp8266 and esp32
* Simple esp8266 Gmail send example
*
* http://mischianti.org/category/my-libraries/emailsender-send-email-with-attachments/
*
*/#include “Arduino.h”
#include <EMailSender.h>
#include <ESP8266WiFi.h>const char* ssid = “xxx”;
const char* password = “xxx”;uint8_t connection_state = 0;
uint16_t reconnect_interval = 10000;// you can set post constructor
//
// void setIsSecure(bool isSecure = true);
void setUseAuth(bool useAuth = true);
void setPublicIpDescriptor(const char *publicIpDescriptor = “mymailde”);// EMailSender emailSend(“smtp.account@gmail.com”, “password”);
// EMailSender(const char* email_login, const char* email_password, const char* email_from, const char* name_from, const char* smtp_server, uint16_t smtp_port );
// EMailSender(const char* email_login, const char* email_password, const char* email_from, const char* smtp_server, uint16_t smtp_port);
// EMailSender(const char* email_login, const char* email_password, const char* email_from, const char* name_from );
// EMailSender(const char* email_login, const char* email_password, const char* email_from);
// EMailSender(const char* email_login, const char* email_password);// müssen Sie in den SMTP-Servereinstellungen den Port von 465 auf 587 ändern und die Verschlüsselung von SSL/TLS auf STARTTLS umstellen
EMailSender emailSend(“myxxx@mail.de”, “xxx”, “myxxx@mail.de”, “smtp.ionos.de”, 465);
uint8_t WiFiConnect(const char* nSSID = nullptr, const char* nPassword = nullptr)
{
static uint16_t attempt = 0;
Serial.print(“Connecting to “);
if(nSSID) {
WiFi.begin(nSSID, nPassword);
Serial.println(nSSID);
}uint8_t i = 0;
while(WiFi.status()!= WL_CONNECTED && i++ < 50)
{
delay(200);
Serial.print(“.”);
}
++attempt;
Serial.println(“”);
if(i == 51) {
Serial.print(“Connection: TIMEOUT on attempt: “);
Serial.println(attempt);
if(attempt % 2 == 0)
Serial.println(“Check if access point available or SSID and Password\r\n”);
return false;
}
Serial.println(“Connection: ESTABLISHED”);
Serial.print(“Got IP address: “);
Serial.println(WiFi.localIP());
return true;
}void Awaits()
{
uint32_t ts = millis();
while(!connection_state)
{
delay(50);
if(millis() > (ts + reconnect_interval) && !connection_state){
connection_state = WiFiConnect();
ts = millis();
}
}
}void setup()
{
Serial.begin(115200);connection_state = WiFiConnect(ssid, password);
if(!connection_state) // if not connected to WIFI
Awaits(); // constantly trying to connectEMailSender::EMailMessage message;
message.subject = “Email Status TEST”;
message.message = “Ciao come stai<br>io bene.<br>LG homa”;EMailSender::Response resp = emailSend.send(“myxxx@mail.de”, message);
Serial.println(“Sending status: “);
Serial.println(resp.status);
Serial.println(resp.code);
Serial.println(resp.desc);
}void loop()
{}
-
21 December 2020 at 22:03 #9019
Hi Matthias,
try to enter inside the library at line 354 change
String helo = "HELO "+String(publicIPDescriptor)+": ";
in
String helo = "EHLO "+String(publicIPDescriptor)+": ";
and give me feedback, if It’s work I do a parameter to manage this option.
Bye Renzo
-
23 December 2020 at 17:29 #9058
Matthias
Hi Renzo,
step by step 😉
my next error 🙁 SMTP AUTH error (250 SIZE 140000000)
17:17:58.529 -> ………….
17:18:00.914 -> Connection: ESTABLISHED
17:18:00.914 -> Got IP address: 192.168.1.131
17:18:00.947 -> ONLY ONE RECIPIENTInsecure client:0
17:18:01.079 -> MFLN supported: yes
17:18:03.546 -> 220 kundenserver.de (mreue109) Nemesis ESMTP Service ready17:18:03.546 -> EHLO mischianti:
17:18:05.745 -> 250-kundenserver.de Hello mischianti: [myIP]17:18:05.745 -> AUTH LOGIN:
17:18:06.345 -> 250-8BITMIME17:18:06.345 -> Encoding
17:18:06.345 -> myEmailUser
17:18:06.345 -> 19
17:18:06.345 -> bTM0Nz myPWD ==
17:18:06.379 -> Encoding
17:18:06.379 -> myEmailUser
17:18:06.379 -> 19
17:18:06.977 -> 250-AUTH LOGIN PLAIN17:18:06.977 -> Encoding
17:18:06.977 -> myPWD in PLAIN
17:18:06.977 -> 22
17:18:06.977 -> U2F my PWD ??? another coding ??? ==
17:18:06.977 -> Encoding
17:18:06.977 -> myPWD in PLAIN again
17:18:06.977 -> 22
17:18:07.575 -> 250 SIZE 14000000017:18:07.575 -> Sending status:
17:18:07.575 -> 0
17:18:07.575 -> 235
17:18:07.575 -> SMTP AUTH error (250 SIZE 140000000) -
23 December 2020 at 22:50 #9059
Hi Matthias,
I check your server
reef@PORTATIREEF:/mnt/c/Users/renzo$ telnet smtp.ionos.de 25 Trying 213.165.67.97... Connected to smtp.ionos.de. Escape character is '^]'. 220 kundenserver.de (mreue010) Nemesis ESMTP Service ready EHLO 213.165.67.97 250-kundenserver.de Hello 213.165.67.97 [XX.X.XX.XX] 250-8BITMIME 250-AUTH LOGIN PLAIN 250-SIZE 140000000 250 STARTTLS
and It implement a SASL Authentication, so I must change the library to support this type of login. I read something and probably we must send a single line with login and passwd.
I’m going to try to do a trial version, I write here when ready to test.
Bye Renzo
-
23 December 2020 at 23:32 #9060
Hi Matthias,
try this version on GitHub branch postfixEMailServer
to activate new features you must add this lines
emailSend.setEHLOCommand(true); emailSend.setSASLLogin(true);
give me a feedback.
Bye Renzo
-
24 December 2020 at 14:18 #9066
matthias
Hi Renzo,
this time the log is much shorter, but the auth error is still there.
The positions with PWD etc. are exactly as in the original log, only here anonymized
Thanks for your efforts!14:09:32.250 -> Connection: ESTABLISHED
14:09:32.250 -> Got IP address: 192.168.1.131
14:09:32.250 -> ONLY ONE RECIPIENTInsecure client:0
14:09:32.417 -> MFLN supported: yes
14:09:33.746 -> 220 kundenserver.de (mreue010) Nemesis ESMTP Service ready14:09:33.746 -> EHLO mischianti:
14:09:33.879 -> 250-kundenserver.de Hello mischianti: […myIP…]14:09:33.879 -> Encoding
14:09:33.879 -> […my@…mail.de] […myPWDinPLAIN…]
14:09:33.879 -> 37
14:09:33.879 -> AUTH PLAIN c21zQ… […myPWDcoded…] …MA==
14:09:34.012 -> 250-8BITMIME14:09:34.012 -> Sending status:
14:09:34.012 -> 0
14:09:34.012 -> 235
14:09:34.012 -> SMTP AUTH error (250-8BITMIME) -
24 December 2020 at 14:20 #9067
matthias
void setup()
{
Serial.begin(115200);connection_state = WiFiConnect(ssid, password);
if(!connection_state) // if not connected to WIFI
Awaits(); // constantly trying to connectEMailSender::EMailMessage message;
message.subject = "Email Status TEST";
message.message = "Ciao come stai<br>io bene.<br>LG matthias";// emailSend.setIsSecure(true);
// emailSend.setUseAuth(true);
// emailSend.setPublicIpDescriptor("iot");
emailSend.setEHLOCommand(true);
emailSend.setSASLLogin(true);EMailSender::Response resp = emailSend.send("homa@efgmail.de", message);
Serial.println("Sending status: ");
Serial.println(resp.status);
Serial.println(resp.code);
Serial.println(resp.desc);
}
-
24 December 2020 at 14:47 #9068
matthias
Hi Renzo,
the problem is that it encrypts the user name and password together.
I think that only the password must be transmitted as base64, right? But how is the user then communicated to the server? Is there maybe a step missing?Bye Matthias
-
24 December 2020 at 19:31 #9069
Mmmm…
probably I don’t flush the buffer try now please.
Bye Renzo
-
25 December 2020 at 14:06 #9071
matthias
hi Renzo, nope 🙁
https://www.fehcom.de/qmail/smtpauth.html
13:51:05.113 -> Connection: ESTABLISHED
13:51:05.113 -> Got IP address: 192.168.1.131
13:51:05.113 -> ONLY ONE RECIPIENTInsecure client:0
13:51:05.179 -> MFLN supported: yes
13:51:06.346 -> 220 kundenserver.de (mreue107) Nemesis ESMTP Service ready13:51:06.346 -> EHLO xxxmymail.de:
13:51:06.446 -> 250-kundenserver.de Hello xxxmymail.de: [myIP]13:51:06.446 -> 250-8BITMIME
13:51:06.446 -> 250-AUTH LOGIN PLAIN
13:51:06.446 -> 250 SIZE 140000000
13:51:46.429 -> Encoding
13:51:46.429 -> [myEmailPLAIN][myPWDPLAIN]
13:51:46.429 -> 36
13:51:46.429 -> AUTH PLAIN [myBASE64string]
13:51:46.528 -> 535 Authentication credentials invalid13:51:46.528 -> Sending status:
13:51:46.528 -> 0
13:51:46.528 -> 235
13:51:46.528 -> SMTP AUTH error (535 Authentication credentials invalid
) -
25 December 2020 at 23:20 #9072
matthias
if (useAuth){
if (this->isSASLLogin == true){
awaitSMTPResponse(client);
awaitSMTPResponse(client);
awaitSMTPResponse(client);
// awaitSMTPResponse(client);
// awaitSMTPResponse(client);
// awaitSMTPResponse(client);
// awaitSMTPResponse(client);
char* logPass = (char*) malloc(1 + strlen(this->email_login) + strlen(this->email_password) + 2);
strcpy(logPass, "\0");
strcat(logPass, this->email_login);
strcat(logPass, "\0");
strcat(logPass, this->email_password);
// strcpy(logPass, "\0");
// strcat(logPass, this->email_login);
// strcat(logPass, "\0");
// strcat(logPass, this->email_password);
String auth = "AUTH PLAIN " + String(encode64(logPass)); // WRONG !!
// this create the right base64 STRING !!! in the commandline / terminal
// $ echo -ne '\0test@xxxmail.de\0testpassword'|base64
// String auth = "AUTH PLAIN AAHRlc3RAeHh4bWFpbC5kZQB0ZXN0cGFzc3dvcmQ="; // WORK !! but with other error later ... timeout when email sending ...
DEBUG_PRINTLN(auth);
client.println(auth);
-
25 December 2020 at 23:45 #9073
Hi Matthias,
I have some problem with \0 (null char), I commit a version but I must check better.
Your version work?
Bye Renzo
-
26 December 2020 at 08:54 #9077
I think I fix the problem.
you can also try to disable isSASLLogin.
Give me a feedback.
Bye Renzo
-
27 December 2020 at 12:45 #9138
matthias
T H A N K Y O U !
That version is it. Mission complete! Happy New Year 😉
12:37:15.355 -> Connection: ESTABLISHED
12:37:15.355 -> Got IP address: 192.168.1.131
12:37:15.355 -> ONLY ONE RECIPIENTInsecure client:0
12:37:15.522 -> MFLN supported: yes
12:37:16.688 -> 220 kundenserver.de (mreue106) Nemesis ESMTP Service ready12:37:16.688 -> EHLO efgmail.de:
12:37:16.788 -> 250-kundenserver.de Hello efgmail.de: [myIP]12:37:16.788 -> 250-8BITMIME
12:37:16.788 -> 250-AUTH LOGIN PLAIN
12:37:16.822 -> 250 SIZE 140000000
12:37:56.788 -> Encoding
12:37:56.788 ->
12:37:56.788 -> 39
12:37:56.788 -> AUTH PLAIN [myBase64pwCORRECT!]
12:37:56.921 -> 235 Authentication succeeded12:37:56.921 -> MAIL FROM: <myxxx@testgmail.de>
12:37:57.088 -> 250 Requested mail action okay, completed12:37:57.088 -> RCPT TO: <myRCPTto@testmail.de>
12:37:57.355 -> 250 OK12:37:57.355 -> DATA:
12:37:57.422 -> 354 Start mail input; end with <CRLF>.<CRLF>12:37:59.588 -> Message end
12:37:59.621 -> 250 Requested mail action okay, completed: id=[theID]12:37:59.721 -> 221 kundenserver.de Service closing transmission channel
12:37:59.721 -> Sending status:
12:37:59.721 -> 1
12:37:59.721 -> 0
12:37:59.721 -> Message sent! -
27 December 2020 at 12:49 #9139
matthias
okay, I was too hasty.
Unfortunately the email is empty. It arrives at the recipient, but without content 🙁
-
27 December 2020 at 13:02 #9140
matthias
THIS IS THE CONTENT SOURCE:
Return-Path: <xxx@testmail.de>
Received: from [217.72.192.67] ([217.72.192.67]) by mx.kundenserver.de
(mxeue111 [217.72.192.67]) with ESMTPS (Nemesis) id 1MnZgJ-1kCyYc3taf-00jRB5
for <xxx@testmail.de>; Sun, 27 Dec 2020 12:37:59 +0100
Received: from mout.kundenserver.de ([217.72.192.73]) by mx.kundenserver.de
(mxeue111 [217.72.192.67]) with ESMTPS (Nemesis) id 1Mw8Q6-1k3rkp3r8O-00rzla
for <xxx@testmail.de>; Sun, 27 Dec 2020 12:37:59 +0100
Received: from XXX: ([myIP]) by mrelayeu.kundenserver.de
(mreue106 [IPAdr]) with ESMTPSA (Nemesis) id
1N7hrw-1jyrHb1eM6-014jge for <xxx@testmail.de>; Sun, 27 Dec 2020 12:37:59
+0100
From: <xxx@testmail.de>
To: <xxx@testmail.de>
MIME-Version: 1.0
Content-Type: Multipart/mixed; boundary=frontier
–frontier
Content-Type: text/html; charset=”UTF-8″
Content-Transfer-Encoding: 7bit
Date: Sun, 27 Dec 2020 12:37:59 +0100
Message-ID: <1Mna0x-1kCyYc2orN-00jcQp@mrelayeu.kundenserver.de>
X-Provags-ID: V03:K1:sx1VIQU88qZRUOq2unVGvSaYYvCev
…
QwBg==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:ip05GG5Crbs=:Z8sx4f5auXeBV
…
pDcJvcb7kn+cow255
Envelope-To: <xxx@testmail.de>
Subject: [SPAM?] Email Status TEST
X-Spam-Flag: YES
X-UI-Filterresults: junk:10;V03:K0:BwtejaETKmM=:nonYreUx2X
…
vLSek0fsBKg/9AvCHiQKFg2gAFJE5cp1PgjzpG2PgUoFAkycVu
axGAVHLGzua9JwtUdLX6kQ7yw==<!DOCTYPE html><html lang=”en”>Ciao come stai<br>io bene.<br>LG matthias</html>
–frontier–
-
27 December 2020 at 16:58 #9141
Hi Matthias,
I’m moved :’) .
The last problem seems the antispam filter that block the content.
Subject: [SPAM?] Email Status TEST X-Spam-Flag: YES X-UI-Filterresults: junk:10;V03:K0:BwtejaETKmM=:nonYreUx2X
Try to send simple text message, or better send message to another email provider (and check spam).
But I think now the flow It’s ok.
Bye Renzo
-
30 December 2020 at 08:03 #9160
Hi matthias,
Any news? Have you found the solution?
Bye Renzo
-
-
AuthorPosts
- You must be logged in to reply to this topic.