Boa noite pessoal,

gostaria de receber e mandar email pelo arduino, principalmente receber. peguei essa programacao e atualizei,mas nao acontece nada. Alguem saberia dizer qual seria o erro que tem nesse codigo?

/*=================================================
Ethernet POP3 Mail Checker & indicator

Checks how many messages are waiting on the POP 3 server
and flashed LED on Pin 9 to indicate number of messages.

It will handle up to 99 messages in the POP3 mailbox.

Uncomment the serial lines for troubleshooting.

Copyright by Chris Armour
3 September 2009
http://opensourceprojects-torchris.blogspot.com/

===================================================*/
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetClient.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,25,50 }; // IP address you wish to assign to Arduino
byte server[] = { 74, 125, 131, 108 }; // IP address of your POP3 server
char inString[165]; // Number of characters to be collected
int i = 0;
int mailNum1 = 0; // First digit of the email number (ESSA PARTE DEIXEI PADRÃO, NAO ENTENDI A FUNÇÃO DELA)
int mailNum2 = 0; // Second digit  (ESSA PARTE DEIXEI PADRÃO, NAO ENTENDI A FUNÇÃO DELA)
int mailTotal = 0; // Total # of messsage  (ESSA PARTE DEIXEI PADRÃO, NAO ENTENDI A FUNÇÃO DELA)
char d;
int ledPin = 9;

EthernetClient client; //The default POP port is 110

long updateTimer;
boolean clientConnected = false;

void setup()
{
// Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}

void loop()
{

updateClient();
d = checkAvail();
if (d >= 10){
getMailNum();
}

}

/*========================================
Functions
=========================================*/

void updateClient() //This function contacts the POP3 server
{
if ((millis() - updateTimer) > 5000)
{
Ethernet.begin(mac, ip);
// Serial.println("connecting...");
delay(1000);
if (client.connect(server, 995))
{
// Serial.println("connected");
client.println("danfrusciant"); //Insert your usual email login name
client.println("minhasenha"); //And your password here
client.println("quit");
client.println();
clientConnected = true;
}
else
{
// Serial.println("connection failed");
}
updateTimer = millis();
}
}

char checkAvail() //This checks if there is data available and returns a char
{
if (clientConnected)
{
if (client.available())
{
char c = client.read();
return(c);
}
if (!client.connected())
{
// Serial.println();
// Serial.println("disconnecting.");
client.stop();
clientConnected = false;
}
}
}

int getMailNum() //This actually loads the char returned by checkAvail() and puts in into an array
{
inString[i] = d;
i++;
if (i == 165){
i = 0;
client.flush();
mailNum1 = inString[106] - 48; //Array position 106 contains the first digit
mailNum2 = inString[107] - 48; //Array position 107 contains the 2nd digit if it is available
if ((mailNum2 >= 0) && (mailNum2 <= 9)){ //If mailNum2 is present, then it is a two digit mail count
mailTotal = (mailNum1 * 10) + mailNum2; //when 2 digits are present, multiply the 1st by 10 then add to mailTotal
// Serial.print("Total emails: ");
// Serial.println(mailTotal);
blinkLED(); //Run the blink function as many times as there are emails
}
else {
if ((mailNum1 >= 0) && (mailNum1 <= 9)){//if there is only one digit, then that is mailTotal
mailTotal = mailNum1;
// Serial.print("Total emails: ");
// Serial.println(mailTotal);
blinkLED(); //Blink the LED
}
}
}
}

void blinkLED(){ //Blinks the LED for as many times as indicated by mailTotal
for(int x = mailTotal; x >= 1; x--){
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}

Exibições: 2562

Responder esta

Respostas a este tópico

Mano, tu tem o código ai antes da alteração?

na linha 

client.println("danfrusciant"); //Insert your usual email login name
client.println("minhasenha"); //And your password here

voce deve colocar seu email e sua senha mas convertido o texto para base de 64 

voce pode fazer isso nesse site

http://www.motobit.com/util/base64-decoder-encoder.asp

faça isso q coloque seus resultados

ha e nao esqueca de colocar o seu ip do pop3 do seu email

nao sabe como fazer?

veja esse video 

https://www.youtube.com/watch?v=0cy_fsaGs50

Blz, Jose, vou fazer esse teste. O IP do POP3 ja tinha colocado (74, 125, 131, 108). O restante esta ok? vc ja implementou essa funcao?

Abs!

 O IP tem que ser fixo ou tem como fazer com IP dinâmico?

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço