Hello
I am trying to send email through the ESP8266.
I managed to log into an smtp server but the HELO/EHLO does not seem to get to the server.
Could anyone help me out?
Thank you
Gabe
#include <AltSoftSerial.h>
AltSoftSerial esp8266; //
#define SERIAL_BUFFER_SIZE 32
#define DEBUG true
#define ssid "xxxxx"
#define password "yyyyyyyyyy"
#define server "smtp.ipower.com"
#define port 587
#define publicIP z.z.z.z
int led = 13;
int v = 0;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
sendData("AT+RST\r\n",2000,DEBUG); // reset module
sendData("AT+CWQAP\r\n",2000,DEBUG); // Quit Access Point
sendData("AT+CWMODE=1\r\n",1000,DEBUG); // configure as access point
String cwjapSend = "AT+CWJAP=\"";
cwjapSend += ssid;
cwjapSend += "\",\"";
cwjapSend += password;
cwjapSend += "\"\r\n";
sendData(cwjapSend,8000,DEBUG);
sendData("AT+CWJAP?\r\n",1000,DEBUG);
sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
sendData("AT+CIPMUX=0\r\n",1000,DEBUG); // configure for multiple connections
String cipstartSend = "AT+CIPSTART=\"TCP\",\"";
cipstartSend += server;
cipstartSend += "\",";
cipstartSend += port;
cipstartSend += ";2\r\n";
sendData(cipstartSend,3000,DEBUG);
String ehlo = "HELO z.z.z.z\r\n";
String cipEHLOSend = "AT+CIPSEND=";
//cipEHLOSend += ",";
cipEHLOSend +=ehlo.length();
cipEHLOSend +="\r\n";
sendData(cipEHLOSend,3000,DEBUG);
// esp8266.print(ehlo);
sendData(ehlo,3000,DEBUG);
}
void loop()
{
if (esp8266.available())
Serial.write(esp8266.read());
if (Serial.available())
esp8266.write(Serial.read());
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command); // send the read character to the esp8266
long int time = millis();
while( (time+timeout) > millis())
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
response+=c;
}
}
if(debug)
{
Serial.print(response);
Serial.flush();
}
return response;
}
void beep()
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
}
This is what I get
OK
ÍÅÛÔÕÕ
ÐÅPôX!æÆHÖ
Vendor:www.ai-thinker.com
SDK Version:0.9.5(b1)
Compiled @:Dec 25 2014, 21:50:58
ready
AT+CWQAP
OK
AT+CWMODE=1
OK
AT+CWJAP="xxxxx","yyyyyyyyyy"
OK
AT+CWJAP?
+CWJAP:"xxxxx"
OK
AT+CIFSR
+CIFSR:STAIP,"192.168.0.12"
+CIFSR:STAMAC,"18:fe:34:9d:2e:1d"
OK
AT+CIPMUX=0
OK
AT+CIPSTART="TCP","smtp.ipower.com",587;2
CONNECT
OK
+IPD,68:220 ESMTP Tue, 28 Apr 2015 09:51:39 -0400: UCE strictly prohibited
OK
AT+CIPSEND=21
> HELO z.z.z.z
+IPD,85:421 bosauthsmtp10.yourhostingaccount.com: SMTP command timeout - closing connection
OK
CLOSED
OK
The process stops after > HELO z.z.z.z and stays there for several minutes until the disconnect message from the smtp server.