Trouble using Gmail's SMTP

Me and a group have been trying to figure out a way to send an email using our MKR1000, we’re able to connect to the internet, and we are trying to use Gmail’s SMTP. It seems that you need to let google know your username and password for your gmail so that you can use the SMTP, but we are confused about how to give google that information through the Arduino. We are new to Arduino so perhaps we are missing something basic? But it’s stumped us. Any tips or suggestions would be much appreciated.

Here is the code that we are using:

#include<dht11.h>
dht11 DHT11;
//static int greenPort = 11;
//static int yellowPort = 12;
//static int redPort = 13;
static int buttonPort = 5;
static int output[]={0,1,2,3};
int buttonState;
int lastButtonState=LOW;
long lastDebounceTime=0;
long debounceDelay = 50;
int count = 0;
char ssid[] = "uscguest";
#include <SPI.h>
#include <WiFi101.h>
 IPAddress ip;
 IPAddress gateway;
 IPAddress subnet;

 char server[] = {74,125,65,27};
 WiFiClient client;
 int status = WL_IDLE_STATUS;
static int segs_encoding[][4] =
 {{0,0,0,0},
   {0,0,0,1},
   {0,0,1,0},
   {0,0,1,1},
   {0,1,0,0},
   {0,1,0,1},
   {0,1,1,0},
   {0,1,1,1},
   {1,0,0,0},
   {1,0,0,1}};
void show(int base, int num){
 for(int i=0;i<4;++i){
   if(segs_encoding[num][i]==1){
     digitalWrite(base+3-i, HIGH);
   }else{
     digitalWrite(base+3-i,LOW);
   }
 }
}
void show_decimal(int base, int num){
 show(base, num);
}
void setup() {
 Serial.begin(9600);
  
 DHT11.attach(14);
 for(int i=0;i<4;++i)
   pinMode(i,OUTPUT);
 for(int i=7;i<11;i++)
   pinMode(i,OUTPUT);

 pinMode(buttonPort, INPUT);

status = WiFi.begin(ssid);
   countCheckDisplay(2); 
   
 ip = WiFi.localIP();
 subnet = WiFi.subnetMask();
 gateway = WiFi.gatewayIP();
}
void countCheckDisplay(int counter){
  if(counter==0)
 {
 int tens = (int)DHT11.fahrenheit()/10;
 int ones = (int)DHT11.fahrenheit()%10;

 show(7, (int)ones);
 show(0, (int)tens);
 }
 else if(counter==1)
 {
 int tens = (int)DHT11.temperature/10;
 int ones = (int)DHT11.temperature%10;

 show(7, (int)ones);
 show(0, (int)tens);
 }
 else if(counter==2)
 {
 int tens = (int)DHT11.humidity/10;
 int ones = (int)DHT11.humidity%10;

 show(7, (int)ones);
 show(0, (int)tens);
   }}
void loop() {
 int chk = DHT11.read();
 switch(chk)
 {
   case 0: break;
   case -1: Serial.println("Checksum error");break;
   case -2: Serial.println("Time out error");break;
   default: Serial.println("Unknown error"); break;
 }
 int reading = digitalRead(buttonPort);
 if(reading!=lastButtonState)
 {
   delay(50);
   if(reading!=lastButtonState){
     buttonState=reading;
//      if(buttonState==HIGH)
//      lastButtonState=LOW;
//      else if(buttonState==LOW)
//      lastButtonState=HIGH;
     if(buttonState==LOW){
      count=count+1;
      if(count>2)
        {
          count=0;
         }
   countCheckDisplay(count);
   delay(5000);
     if(status==WL_CONNECTED){
   show(7,1);
   show(0,1);}
 else{
   show(0,9);
   show(7,9);}
   }
   }
 }
 lastButtonState = reading;
//  if(reading!=lastButtonState){
//    lastDebounceTime=millis();
//  }
//  if(millis()-lastDebounceTime>debounceDelay){
//    buttonState = reading;
//  }
   
//    countCheckDisplay(2);
//    delay(2000); 
 }

void sendEmail()
{
 byte thisByte = 0;
 byte respCode;
 if(client.connectSSL(server,465)){
   Serial.println("connected");
   Serial.println(client.read());
 }
 else{
   Serial.println("connection failed");
   return;
 }
 if(!eRcv())return;
 client.write("AUTH");
 client.write("username@gmail.com");
 client.write("password");
     Serial.println(client.read());
 client.write("helo 129.252.30.6\r\n");
     Serial.println(client.read());
 if(!eRcv())return;
 Serial.println("Sending email");

 client.write("MAIL From: <amwboys1@gmail.com>\r\n");
     Serial.println(client.read());
 if(!eRcv())return;
 Serial.println("SendingTo");
 client.write("RCPT To: <amwboys1@outlook.com>\r\n");
     Serial.println(client.read());
 if(!eRcv())return;
 client.write("DATA\r\n");
     Serial.println(client.read());
 if(!eRcv())return;
 client.write("To: You <amwboys1@outlook.com>\r\n");
 client.write("From: Me <amwboys1@gmail.com>\r\n");
 client.write("Subject: Temp Test\r\n");
 client.write("Temperature F: ");
 client.write(DHT11.fahrenheit());
 client.write("Temperature C: ");
 client.write(DHT11.temperature);
 client.write("Humidity: ");
 client.write(DHT11.humidity);
 client.write("\r\n");
 client.write(".\r\n");

 if(!eRcv())return;
 client.write("QUIT\r\n");
 if(!eRcv())return;
 client.stop();
}
byte eRcv()
{
 byte respCode;
 byte thisByte;
 int loopCount = 0;

 while(!client.available()){
   delay(1);
   loopCount++;
   if(loopCount>10000){
     client.stop();
     Serial.println("\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.write("QUIT\r\n");
 while(!client.available()){
   delay(1);
   loopCount++;
   if(loopCount>10000){
     client.stop();
     Serial.println("\r\nTimeout");
     return;
   }
 }
 while(client.available())
 {
   thisByte=client.read();
   Serial.write(thisByte);
 }
 client.stop();
 Serial.println("disconnected");
}

Edit your post and insert code tags. You may see yourself how the text so the code isn't readable and misses some content.

Also post the output you get on the serial monitor!

The AUTH command must be sent after the EHLO command and the complete command is "AUTH LOGIN".

pylon:
Edit your post and insert code tags. You may see yourself how the text so the code isn't readable and misses some content.

Also post the output you get on the serial monitor!

The AUTH command must be sent after the EHLO command and the complete command is "AUTH LOGIN".

We were able to get the program to work! Thanks for the help!

rocklee_bestboy:
We were able to get the program to work! Thanks for the help!

Would you mind sharing the solution, please?

Thanks