First of all, I tried the smtp sample “samples/tcpip/smtp/smtp.c” and everything worked fine, no problems here.
Then I introduced the smtp code inside this function :
//( previously defined macros )
#define FROM "agmangas@SmtpServerName.com"
#define TO "agmangas@gmail.com"
#define SUBJECT "Alarm Activated"
#define BODY "An alarm has been activated, visit the web for more information"
#define SMTP_SERVER "SmtpServerName"
#define USE_SMTP_AUTH
#define SMTP_VERBOSE
#define SMTP_DEBUG
void enviarMail(){
while (ifpending(IF_DEFAULT) == IF_COMING_UP) {
tcp_tick(NULL);
}
smtp_setauth ("xxxxx@SmtpServerName.com", "xxxxx");
smtp_sendmail(TO, FROM, SUBJECT, BODY);
while(smtp_mailtick()==SMTP_PENDING)
continue;
if(smtp_status()==SMTP_SUCCESS)
printf("Message sent
");
else
printf("Error sending message
");
}
this function is called inside a costatement of the global code I�m developing, but it produced the following error :
SMTP: Resolving "SmtpServerName"
SMTP: Error resolving server(-2)
I tried writing the IP of the SMTP Server instead of its name, but there was a different error :
SMTP: Resolving xxx.xxx.xxx.xxx
SMTP: Opening to D595FD08:25
Error opening socket
This is how the main function looks like :
main(){
... Variables Initialization ...
[I][B]call[/B][/I]
while(1){
http_handler();
[I][B]call[/B][/I]
costate {
waitfor(BitRdPortI(PDDR,5)==1);
waitfor(DelayMs(2000));
waitfor(BitRdPortI(PDDR,5)==1);
strcpy(AChar1,"Aon.gif");
[I][B]call[/B][/I]
waitfor(BitRdPortI(PDDR,5)==0);
strcpy(AChar1,"Aoff.gif");
}
... The same costatement repited 6 times with different port values ...
}//while
}//main
When I call “enviarMail()” in the places marked in blue, the function works, but it doesn�t work with the red ones, I can�t figure out how to fix it…
Any help would be appreciated, thanks in advance.