-
Notifications
You must be signed in to change notification settings - Fork 9
/
Mail.ino
59 lines (51 loc) · 1.6 KB
/
Mail.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifdef USE_MAIL
EthernetClient mailClient;
void SendMail()
{
if(mailClient.connect(MAIL_SERVER,25))
{
if(CheckResponse())
{
mailClient << F("HELO Arduino") << endl; // say hello
if(CheckResponse())
{
mailClient << F("MAIL FROM:" MAIL_FROM) << endl; // identify sender
if(CheckResponse())
{
mailClient << F("RCPT TO:" MAIL_TO) << endl; // identify recipient
if(CheckResponse())
{
mailClient << F("DATA") << endl;
if(CheckResponse())
{
mailClient << F("Subject:SolarMeter ") << day() << endl; // insert subject
mailClient << F("Content-type: text/html;") << endl << endl;
ShowStatus(mailClient);
mailClient << endl << F(".") << endl; // end of mail
if(CheckResponse())
{
mailClient << F("QUIT") << endl; // terminate connection
}
}
}
}
}
}
mailClient.stop();
}
}
boolean CheckResponse()
{
return mailClient.find((char*)"\n");
// long timer = millis();
// while(millis() - timer < 5000)
// {
// if(mailClient.available())
// {
// char c = mailClient.read();
// if(c=='\n') return true;
// }
// }
// return false;
}
#endif