4G Email Sending Failure

Wireless communications in Waspmote, topologies, node types...
Post Reply
mikismart
Posts: 25
Joined: Thu Jul 11, 2019 8:33 am
Company: Samek Engineering

4G Email Sending Failure

Post by mikismart » Sat Jul 13, 2019 10:18 am

i have been trying to send an email from Smart Environment Pro and here is the code

Code: Select all

#include <Wasp4G.h>

// APN settings
///////////////////////////////////////
char apn[] = "etc";
char login[] = "";
char password[] = "";
///////////////////////////////////////


// E-mail sender parameters
//////////////////////////////////////////////////
char sender_address[] = "xxxxx@yahoo.com";
char sender_user[] = "xxxxxx@yahoo.com";
char sender_password[] = "xxxxxx";
//////////////////////////////////////////////////

// E-mail SMTP parameters
//////////////////////////////////////////////////
char smtp_server[] = "smtp.mail.yahoo.com";
uint8_t smtp_security = Wasp4G::EMAIL_SSL;
uint16_t smtp_port = 465;
//////////////////////////////////////////////////

// E-mail to send
//////////////////////////////////////////////////
char receiver_address[] = "xxxxxxx@gmail.com";
char subject[] = "Subject of email"; // maximum: 100 bytes
char message[] = "This is an e-mail message from Waspmote";
//////////////////////////////////////////////////

// variable
uint8_t error;
uint8_t connection_status;

void setup()
{
  USB.ON();
  USB.println(F("Start program"));

  //////////////////////////////////////////////////
  // Set operator parameters
  //////////////////////////////////////////////////
  _4G.set_APN(apn, login, password);


  //////////////////////////////////////////////////
  // Show APN settings via USB port
  //////////////////////////////////////////////////
  _4G.show_APN();


  //////////////////////////////////////////////////
  // 1. Switch on the 4G module
  //////////////////////////////////////////////////
  error = _4G.ON();

  if (error == 0)
  {
    USB.println(F("1. 4G module ready..."));

    ////////////////////////////////////////////////
    // 1.1. Reset e-mail parameters
    ////////////////////////////////////////////////

    error = _4G.emailReset();

    if (error == 0)
    {
      USB.println(F("1.1. Reset e-mail parameters OK"));
    }
    else
    {
      USB.print(F("1.1. Error reset configuration. Code: "));
      USB.println(error, DEC);
    }

    ////////////////////////////////////////////////
    // 1.2. Set SMTP server
    ////////////////////////////////////////////////
    error = _4G.emailSetServerSMTP(smtp_server);

    if (error == 0)
    {
      USB.println(F("1.2. SMTP server set OK"));
    }
    else
    {
      USB.print(F("1.2. Error set server. Code: "));
      USB.println(error, DEC);
    }

    ////////////////////////////////////////////////
    // 1.3. Configure SMTP server security and port
    ////////////////////////////////////////////////
    error = _4G.emailConfigureSMTP(smtp_security, smtp_port);

    if (error == 0)
    {
      USB.println(F("1.3. Configure SMTP server OK"));
    }
    else
    {
      USB.print(F("1.3. Error configuring SMTP server. Code: "));
      USB.println(error, DEC);
    }

    ////////////////////////////////////////////////
    // 1.4. Set sender address
    ////////////////////////////////////////////////
    error = _4G.emailSetSender(sender_address, sender_user, sender_password);

    if (error == 0)
    {
      USB.println(F("1.4. Sender addres set OK"));
    }
    else
    {
      USB.print(F("1.4. Error set address. Code: "));
      USB.println(error, DEC);
    }

    ////////////////////////////////////////////////
    // 1.5. Save e-mail configuration settings
    ////////////////////////////////////////////////
    error = _4G.emailSave();

    if (error == 0)
    {
      USB.println(F("1.5. Save configuration OK"));
    }
    else
    {
      USB.print(F("1.5. Error saving configuration. Code: "));
      USB.println(error, DEC);
    }

  }
  else
  {
    USB.print(F("1. Error starting module. Code: "));
    USB.println(error, DEC);
  }

  USB.println(F("*** Setup done ***\n\n"));
}




void loop()
{
  //////////////////////////////////////////////////
  // 1. Switch ON
  //////////////////////////////////////////////////
  error = _4G.ON();

  if (error == 0)
  {
    USB.println(F("1. 4G module ready..."));

    ////////////////////////////////////////////////
    // 2. Send e-mail
    ////////////////////////////////////////////////
    connection_status = _4G.checkDataConnection(30);

    if (connection_status == 0)
    {
      USB.println(F("1.1. Module connected to network"));

      // delay for network parameters stabilization
      delay(5000);

      //////////////////////////////////////////////
      // 1.2. Get RSSI
      //////////////////////////////////////////////
      error = _4G.getRSSI();
      if (error == 0)
      {
        USB.print(F("1.2. RSSI: "));
        USB.print(_4G._rssi, DEC);
        USB.println(F(" dBm"));
      }
      else
      {
        USB.println(F("1.2. Error calling 'getRSSI' function"));
      }
    }
    else {
      USB.println(F("Data Connection failed"));
    }
    error = _4G.emailSend(receiver_address, subject, message);

    if (error == 0)
    {
      USB.println(F("2. Sending e-mail OK"));
    }
    else
    {
      USB.print(F("2. Error sending e-mail. Code: "));
      USB.println(error, DEC);
    }
  }
  else
  {
    // Problem with the communication with the 4G module
    USB.print(F("1. 4G module not started. Error code: "));
    USB.println(error, DEC);
  }

  ////////////////////////////////////////////////
  // 3. Powers off the 4G module
  ////////////////////////////////////////////////
  USB.println(F("3. Switch OFF 4G module"));
  _4G.OFF();


  ////////////////////////////////////////////////
  // 4. Sleep
  ////////////////////////////////////////////////
  USB.println(F("4. Enter deep sleep..."));
  PWR.deepSleep("00:00:10:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);

  USB.ON();
  USB.println(F("5. Wake up!!\n\n"));
}

and here is the output so could you tell me what is the problem and how can i fix it.
Start program
*****************************
APN: etc
LOGIN: etc
PASSWORD: etc
*****************************
1. 4G module ready...
1.1. Reset e-mail parameters OK
1.2. SMTP server set OK
1.3. Configure SMTP server OK
1.4. Sender addres set OK
1.5. Save configuration OK
*** Setup done ***


1. 4G module ready...
Data Connection failed
2. Error sending e-mail. Code: 2
3. Switch OFF 4G module
4. Enter deep sleep...
Regards

mikismart
Posts: 25
Joined: Thu Jul 11, 2019 8:33 am
Company: Samek Engineering

Re: 4G Email Sending Failure

Post by mikismart » Sat Jul 13, 2019 10:31 am

the output i got after restarting the device
Start program
*****************************
APN: etc
LOGIN: etc
PASSWORD: etc
*****************************
1. 4G module ready...
1.1. Reset e-mail parameters OK
1.2. SMTP server set OK
1.3. Configure SMTP server OK
1.4. Sender addres set OK
1.5. Save configuration OK
*** Setup done ***


1. 4G module ready...
1.1. Module connected to network
1.2. RSSI: -65 dBm
2. Error sending e-mail. Code: 2
3. Switch OFF 4G module
4. Enter deep sleep...
so then how do i confirm the module to send the Email and stop waiting for it

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: 4G Email Sending Failure

Post by libelium-dev » Tue Jul 16, 2019 8:04 am

Hi,

Could you please try with another smtp server? We have tried using our server and port 25 and it works.

In addition, please try to add the follwoing lines of code before _4G.emailConfigureSMTP() function

Code: Select all

printString("SSLEN=1,1\r",1);
delay(2000);
Regards

mikismart
Posts: 25
Joined: Thu Jul 11, 2019 8:33 am
Company: Samek Engineering

Re: 4G Email Sending Failure

Post by mikismart » Tue Jul 16, 2019 10:11 am

Hi
Us you say to use an other smtp server, we are using 3 servers yahoo, gmail, mansoftweb smtp but we get the same output/result as we shown below using the same code except the smtp will be changed. and also when we use Wasp4G::MAIL_NONSSL error code 2 is generated that is 2: if error waiting for module confirmation what I have left?
#include <Wasp4G.h>

// APN settings
///////////////////////////////////////
char apn[] = "etc";
char login[] = "etc";
char password[] = "xxx";
///////////////////////////////////////


// E-mail sender parameters
//////////////////////////////////////////////////
char sender_address[] = "test@mansoftweb.com";
char sender_user[] = "test@mansoftweb.com";
char sender_password[] = "xxxx";
//////////////////////////////////////////////////or
char sender_address[] = "ictatsamek@yahoo.com";
char sender_user[] = "ictatsamek@yahoo.com";
char sender_password[] = "xxxx";
//////////////////////////////////////////////////and this one
char sender_address[] = "tigabie1212@gmail.com";
char sender_user[] = "tigabie1212@gmail.com";
char sender_password[] = "xxxx";
// E-mail SMTP parameters
//////////////////////////////////////////////////
char smtp_server[] = "mail.mansoftweb.com";
uint8_t smtp_security = Wasp4G::EMAIL_SSL; ////if we use NONSSL IT IS NOT SENT EMAIL OK OUTPUT
uint16_t smtp_port = 587; //ports 25 and 465 for gmail 587 for yahoo
//////////////////////////////////////////////////

// E-mail to send
//////////////////////////////////////////////////
char receiver_address[] = "ictatsamek@yahoo.com";//we are use different email receivers
char subject[] = "Subject of email"; // maximum: 100 bytes
char message[] = "This is an e-mail message from Waspmote";
//////////////////////////////////////////////////

// variable
uint8_t error;


void setup()
{
USB.ON();
USB.println(F("Start program"));

//////////////////////////////////////////////////
// Set operator parameters
//////////////////////////////////////////////////
_4G.set_APN(apn, login, password);


//////////////////////////////////////////////////
// Show APN settings via USB port
//////////////////////////////////////////////////
_4G.show_APN();


//////////////////////////////////////////////////
// 1. Switch on the 4G module
//////////////////////////////////////////////////
error = _4G.ON();

if (error == 0)
{
USB.println(F("1. 4G module ready..."));

////////////////////////////////////////////////
// 1.1. Reset e-mail parameters
////////////////////////////////////////////////

error = _4G.emailReset();

if (error == 0)
{
USB.println(F("1.1. Reset e-mail parameters OK"));
}
else
{
USB.print(F("1.1. Error reset configuration. Code: "));
USB.println(error, DEC);
}

////////////////////////////////////////////////
// 1.2. Set SMTP server
////////////////////////////////////////////////
error = _4G.emailSetServerSMTP(smtp_server);

if (error == 0)
{
USB.println(F("1.2. SMTP server set OK"));
printString("SSLEN=1,1\r",1);
delay(2000);
}
else
{
USB.print(F("1.2. Error set server. Code: "));
USB.println(error, DEC);
}

////////////////////////////////////////////////
// 1.3. Configure SMTP server security and port
////////////////////////////////////////////////
error = _4G.emailConfigureSMTP(smtp_security, smtp_port);

if (error == 0)
{
USB.println(F("1.3. Configure SMTP server OK"));
}
else
{
USB.print(F("1.3. Error configuring SMTP server. Code: "));
USB.println(error, DEC);
}

////////////////////////////////////////////////
// 1.4. Set sender address
////////////////////////////////////////////////
error = _4G.emailSetSender(sender_address, sender_user, sender_password);

if (error == 0)
{
USB.println(F("1.4. Sender addres set OK"));
}
else
{
USB.print(F("1.4. Error set address. Code: "));
USB.println(error, DEC);
}

////////////////////////////////////////////////
// 1.5. Save e-mail configuration settings
////////////////////////////////////////////////
error = _4G.emailSave();

if (error == 0)
{
USB.println(F("1.5. Save configuration OK"));
}
else
{
USB.print(F("1.5. Error saving configuration. Code: "));
USB.println(error, DEC);
}
}
else
{
USB.print(F("1. Error starting module. Code: "));
USB.println(error, DEC);
}

USB.println(F("*** Setup done ***\n\n"));
}




void loop()
{
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = _4G.ON();

if (error == 0)
{
USB.println(F("1. 4G module ready..."));

////////////////////////////////////////////////
// 2. Send e-mail
////////////////////////////////////////////////
error = _4G.emailSend(receiver_address, subject, message);

if (error == 0)
{
USB.println(F("2. Sending e-mail OK"));
}
else
{
USB.print(F("2. Error sending e-mail. Code: "));
USB.println(error, DEC);
}
}
else
{
// Problem with the communication with the 4G module
USB.print(F("1. 4G module not started. Error code: "));
USB.println(error, DEC);
}

////////////////////////////////////////////////
// 3. Powers off the 4G module
////////////////////////////////////////////////
USB.println(F("3. Switch OFF 4G module"));
_4G.OFF();


////////////////////////////////////////////////
// 4. Sleep
////////////////////////////////////////////////
USB.println(F("4. Enter deep sleep..."));
PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);

USB.ON();
USB.println(F("5. Wake up!!\n\n"));
}
that code is generating the following outputs
Start program
*****************************
APN: etc
LOGIN: etc
PASSWORD: etc
*****************************
1. 4G module ready...
1.1. Reset e-mail parameters OK
1.2. SMTP server set OK
1.3. Configure SMTP server OK
1.4. Sender addres set OK
1.5. Save configuration OK
*** Setup done ***


1. 4G module ready...
2. Sending e-mail OK
3. Switch OFF 4G module
4. Enter deep sleep...
5. Wake up!!


1. 4G module ready...
2. Error sending e-mail. Code: 2
3. Switch OFF 4G module
4. Enter deep sleep...
5. Wake up!!


1. 4G module ready...
2. Error sending e-mail. Code: 2
3. Switch OFF 4G module
4. Enter deep sleep...
5. Wake up!!

1. 4G module ready...
2. Error sending e-mail. Code: 1
3. Switch OFF 4G module
4. Enter deep sleep...
5. Wake up!!
but also the first "sending email OK "output is not real because their is not send history from sender and no delivering to receiver mail box.
please help me to clear this issue?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: 4G Email Sending Failure

Post by libelium-dev » Tue Jul 16, 2019 11:06 am

Hi,

Sorry, the above command is wrong. Please add the following lines.

Code: Select all

printString("AT#SSLEN=1,1\r",1);
delay(2000);
The SMTP parameters from google don't work since it uses TLS and it isn't supported by the 4G module.

Regards

mikismart
Posts: 25
Joined: Thu Jul 11, 2019 8:33 am
Company: Samek Engineering

Re: 4G Email Sending Failure

Post by mikismart » Tue Jul 16, 2019 11:38 am

Hi
stile not solved the same issue happen

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: 4G Email Sending Failure

Post by libelium-dev » Thu Jul 18, 2019 8:59 am

Hi,

Apologies for the delay answering, we were out of the office yesterday.

We have checked the yahoo is also not compatible since port 587 uses TLS. Could you please try with a server that uses port 25 without security?

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest