Hi,
I have a problem sending an email via smtp2go.
I read many posts but did not run into my problem. I am following very closely the smtp2go example code but I a still get errors.
I can successfully connect (port 2525 or 25) and login with my credentials.
Sending the command
"MAIL From: mymail@xy.com"
receives the response "334 UGFzc3dvcmQ6"
Looks OK to me.
Sending the command
"RCPT To: friendmail@xy.com"
receives the response "501 Invalid base64 data"
from then on I receive only error messages. You can find the complete server response is attached below.
With an smtp tool, I can send an email with the exaxt commands I use in arduino.
Any help is appreciated.
Best,
Kai
#include <WiFi.h>
#include <SPI.h>
#include <SD.h>
byte mac[] = { 0x30, 0xAE, 0xA4, 0x1B, 0x99, 0x9C };
byte ip[] = { 192, 168, 178, 79 };
char mailServer[] = "mail.smtp2go.com";
int port = 2525;
WiFiClient client;
File myFile;
void setup() {
Serial.begin(115200);
delay(100);
wificonnect();
sendmails();
client.stop();
}
void loop()
{
}
void wificonnect()
{
//connection works
}
void sendmails()
{
int i,j;
Serial.println("\nStarting connection to server...");
if (!client.connect(mailServer,port))
{
Serial.print("Connection failed to: ");
Serial.println(mailServer);
delay(10000);
}
else
{
Serial.println("Connected to server: ");
Serial.println(mailServer);
Serial.println(F("Sending Helo"));
client.println("EHLO 192.168.178.79");
readResponse();
Serial.println(F("Sending auth login"));
client.println("AUTH LOGIN");
readResponse();
Serial.println(F("Sending User"));
client.println("encoded user");
readResponse();
Serial.println(F("Sending Password"));
Serial.println("encoded pass");
readResponse();
Serial.println(F("MAIL From: mymail@xy.com"));
client.println("MAIL From: mymail@xy.com");
readResponse();
Serial.println(F("RCPT To: friendmail@xy.com"));
client.println("RCPT To: friendmail@xy.com");
readResponse();
Serial.println(F("Sending DATA"));
client.println("DATA");
readResponse();
Serial.println(F("Sending email"));
client.println("To: Kai <kai@....com>");
readResponse();
client.println("From: Susan sender@example.com");
readResponse();
client.println("Subject: Your Subject");
readResponse();
client.println("Hi! Simple test message");
readResponse();
client.println(".");
readResponse();
Serial.println(F("Sending QUIT"));
client.println("QUIT");
readResponse();
}
}
void readResponse()
{
int i;
for (i=1; i<1000; i++)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
}
delay(5000);
}
Starting connection to server...
Connected to server:
mail.smtp2go.com
Sending Helo
220 mail.smtp2go.com ESMTP Exim 4.89 Sun, 22 Apr 2018 09:25:32 +0000
Sending auth login
250-mail.smtp2go.com Hello 192.168.178.79 [91.15.234.128]
250-SIZE 52428800
250-8BITMIME
250-DSN
250-PIPELINING
250-AUTH CRAM-MD5 PLAIN LOGIN
250-STARTTLS
250-PRDR
250 HELP
Sending User
334 VXNlcm5hbWU6
Sending Password
MTFyUjc5MUNWaHA2
MAIL From: mymail@xy.com
334 UGFzc3dvcmQ6
RCPT To: friendmail@xy.com
501 Invalid base64 data
Sending DATA
503 sender not yet given
Sending email
503-All RCPT commands were rejected with this error:
503-503 sender not yet given
503 valid RCPT command must precede DATA
500 unrecognized command
500-unrecognized command
500 Too many syntax or protocol errors
Sending QUIT