Go Down

Topic: sending mail using arduino uno wifi rev2 (Read 341 times) previous topic - next topic

MohamadMohamad

hello

i am trying to send data in a mail using arduino uno wifi rev2, i tried this program but it doesn't work.
the arduino is already connected to the wifi.
could you check the following program and tell me what i have to change or any suggestions ?

thanks.

#include <WiFiNINA.h>
#include <SPI.h>


char from [] = "arduinounowifirev2@yahoo.com";      // email of sender
char password [] = "xxxxxxxxx";                     // email password
char to [] = "xxxxxxxxxxx";
char sub [] = "Results";


String from_base64 = ("YXJkdWlub3Vub3dpZmlyZXYyQHlhaG9vLmNvbQ==");    // email of sender in base64
String password_base64 = ("xxxxxxxxxx");                            // email password in base64

const String host [] = "pop.mail.yahoo.com";
const String port [] = "995";


wifi.connect ( host , port );

  if (wifi.connect(host, port)) {

  Serial.println ( " access to server " );
   
  wifi.println("EHLO kltan");
  wifi.println(F("250"));
 
  wifi.println("AUTH LOGIN");
  wifi.println(F("334 YXJkdWlub3Vub3dpZmlyZXYyQGhvdG1haWwuY29t"));
 
  wifi.println (from_base64);
  wifi.println(F("334 bWhhbWFkMTIz"));

  wifi.println ( password_base64 );
  wifi.println ( F ("235"));
 

  char mailfrom [20] = "MAIL FROM:<";
  strcat ( mailfrom , from );
  strcat ( mailfrom , ">" );

  wifi.println ( mailfrom );
  wifi.println (F ("250"));
 
  char mailto [20] = "RCPT TO:<";
  strcat ( mailto , to );
  strcat ( mailto , ">" );

  wifi.println ( mailto );
  wifi.println ( F ("250"));
 
 
  wifi.println ( "DATA" );
  wifi.println ( F ("354"));

  char efrom [50] = "FROM: ";
  strcat ( efrom , from );
  strcat ( efrom , " " );
  strcat ( efrom , "<" );
  strcat ( efrom , from );
  strcat ( efrom , ">" );
  wifi.println ( efrom );

 

  char eto [50] = "TO: ";
  strcat ( eto , to );
  strcat ( eto , " " );
  strcat ( eto , "<" );
  strcat ( eto , to );
  strcat ( eto , ">" );
  wifi.println ( eto );
 


  char subject [50] = "SUBJECT: ";
  strcat ( subject , sub );
  wifi.println ( subject );
 

  wifi.println ( "\r\n" );

  wifi.println ("welcome to Arduino, we will count the results and send them each 5 min. ");
 
  wifi.println ( "\r\n" );
 
  wifi.println ( "QUIT" );
   
  }else{

    Serial.println ( " couldn't access to server " );
  }

pert

Is that your full sketch?


Please use code tags when you post code or warning/error messages. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don't want to be in the code tags. If your browser doesn't show the posting toolbar, then you can manually add the code tags like this:
[code]// your code is here[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the "How to use this forum" post. Please read it.

Go Up