Go Down

Topic: SMTP hotmail with arduino sheild (Read 2285 times) previous topic - next topic

btsp

I have been trying to send emails with hotmail through SMTP.

here is my code, i got the code from "Beginning Arduino" -Michael McRoberts

but i cannot seem to work, says the email was sent, but i get nothing in my email.

Code: [Select]

#include <Ethernet.h>
#include <SPI.h>
#include <Wire.h>

#define time 1000
#define emailInterval 60

float tempC, tempF;

char message1[35], message2[35];
char subject[] = "Arduino: WAHOOOO!";
unsigned long lastMessage;

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x38, 0xC3};
byte ip[] = {192, 168, 0, 205};
byte server[] = { 65,55,162,200};

Client client(server, 25);

void sendEmail(char subject[], char message1[], char message2[])
  {
    Serial.println("connecting...");
   
    if(client.connect())
        {
          Serial.println ("connected");
          client.println ("HELO hotmail.com");
          delay (time);
          //client.println ("STARTTLS");
          delay (time);
          client.println ("AUTH LOGIN");
          delay (time);
          client.println("64base user name ");
          delay (time);
          client.println("64 base pass");
          delay (time);
          client.println ("MAIL FROM: cam_the_man007@hotmail.com");
          delay  (time);
          client.println ("RCPT TO: cam_the_man007@hotmail.com ");
          delay (time);
          client.println ("DATA");
          delay (time);
          client.println ("FROM: cam_the_man007@hotmail.com");
          delay (time);
          client.println ("TO: cam_the_man007@hotmail.com");
          delay (time);
          client.println ("SUBJECT: ");
          delay (time);
          client.println (subject);
          delay (time);
          client.println (".");
          delay (time);
          client.println ("Quit");
          delay (time);
          Serial.println ("Email Sent");
          delay (time);
        }
        else
          {
            Serial.println("connection failed");
          }
  }
    void checkEmail()
          {
            while (client.available())
                {
                  char c = client.read();
                  Serial.println(c);
                }
            if (!client.connected())
                {
                  Serial.println("disconnecting");
                  client.stop();
                }
          }
         
      void setup()
        {
          Ethernet.begin(mac, ip);
          Serial.begin(9600);
          delay(1000);
        }
       
      void loop()
        {
          sendEmail(subject, message1, message2 );
          if(client.available())
            {
              checkEmail();
            }
        }       



I try doing these commands in command prompt, but it asks for STARTTLS, and as well when i run this code when i get the feedback, so i put a STARTTLS in the code. but it says the server is ready, then disconnects in command prompt. Not sure if thats what its doing for the arduino.

Any hints?
Im not 1005 on the ip address i ping smtp.live.com to get the IP addresss.


btsp

this is the result i get with the STARTTLS command in there.

Code: [Select]

connected
Email Sent
220 BLU0-SMTP196.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at  Fri, 3 Jun 2011 07:39:11 -0700
250 BLU0-SMTP196.phx.gbl Hello [72.14.175.242]
220 2.0.0 SMTP server ready
disconnecting
connecting...
connected
Email Sent
220 BLU0-SMTP166.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at  Fri, 3 Jun 2011 07:39:26 -0700
250 BLU0-SMTP166.phx.gbl Hello [72.14.175.242]
220 2.0.0 SMTP server ready




Go Up