SMTP2Go Question


does know if free account of smtp2go has wait period between connections? using standard code found send myself text via email. works times connection fails if wait 5 mins works again. @ first when sending , receiving email account able connect , send back. have searched online haven't been able find answers. have experience service might know whats going on. below code pertinent details removed.

code: [select]


#include <spi.h>
#include <ethernet.h>

// must unique
byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x59, 0x67 };
// change network settings yours
ipaddress ip(192, 168, 11, 12);
ipaddress gateway(192, 168, 11, 1);
ipaddress subnet(255, 255, 255, 0);

char server[] = "smtp2go.com";
int port = 2525;

ethernetclient client;

void setup()
{
serial.begin(115200);
pinmode(4, output);
digitalwrite(4, high);
ethernet.begin(mac, ip);//, ip, gateway, gateway, subnet);
serial.println("setting ethernet.");
delay(30000);
serial.println(ethernet.localip());
}

void loop()
{

if (sendemail()) serial.println(f("email sent"));
else serial.println(f("email failed"));
while (1)
{
//endless loop.
}
}

byte sendemail()
{
byte thisbyte = 0;
byte respcode;

if (client.connect(server, port) == 1) {
serial.println(f("connected"));
}
else {
serial.println(f("connection failed"));
return 0;
}

if (!ercv()) return 0;

serial.println(f("sending hello"));
// replace 1.2.3.4 arduino's ip
client.println("ehlo 192.168.11.12");
if (!ercv()) return 0;

serial.println(f("sending auth login"));
client.println("auth login");
if (!ercv()) return 0;

serial.println(f("sending user"));
// change base64 encoded user
client.println("########");

if (!ercv()) return 0;

serial.println(f("sending password"));
// change base64 encoded password
client.println("########");


if (!ercv()) return 0;

// change email address (sender)
serial.println(f("sending from"));
client.println("mail from: <email@blaa.com>");
if (!ercv()) return 0;

// change recipient address
serial.println(f("sending to"));
client.println("rcpt to: <1111111111@vtext.com>");
if (!ercv()) return 0;

serial.println(f("sending data"));
client.println("data");
if (!ercv()) return 0;

serial.println(f("sending email"));

// change recipient address
client.println("to: <1111111111@vtext.com>");

// change address
client.println("from: me <email@blaa.com>");

client.println("subject: arduino email test\r\n");

client.println("this arduino!");

client.println(".");

if (!ercv()) return 0;

serial.println(f("sending quit"));
client.println("quit");
if (!ercv()) return 0;

client.stop();

serial.println(f("disconnected"));

return 1;
}

byte ercv()
{
byte respcode;
byte thisbyte;
int loopcount = 0;

while (!client.available()) {
delay(1);
loopcount++;

// if nothing received 10 seconds, timeout
if (loopcount > 10000) {
client.stop();
serial.println(f("\r\ntimeout"));
return 0;
}
}

respcode = client.peek();

while (client.available())
{
thisbyte = client.read();
serial.write(thisbyte);
}

if (respcode >= '4')
{
efail();
return 0;
}

return 1;
}


void efail()
{
byte thisbyte = 0;
int loopcount = 0;

client.println(f("quit"));

while (!client.available()) {
delay(1);
loopcount++;

// if nothing received 10 seconds, timeout
if (loopcount > 10000) {
client.stop();
serial.println(f("\r\ntimeout"));
return;
}
}

while (client.available())
{
thisbyte = client.read();
serial.write(thisbyte);
}

client.stop();

serial.println(f("disconnected"));
}

wouldn't make more sense ask smtp2go people?


Arduino Forum > Using Arduino > Programming Questions > SMTP2Go Question


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts