2019-02-03 07:51 AM
I use NUCLEO-H743ZI board and i have create an http server using RTOS (FreeRTOS API's). My server works good. Now i'm trying to test sending message from a request email to a destination email. I use the functions and definitions based on smtp.c and smtp.h files. This is the section of my code that i use:
/**** send an email using SMTP ****/
void sendAnEmail(void)
{
#define emailFrom "marfourna@yahoo.gr"
#define emailTo "mario.fournaris@gmail.com"
#define emailSubject "annoying"
#define emailMessage "this is an annoying message"
int * some_argument = 0;
//IP address or DNS name for your SMTP connection
smtp_set_server_addr("smtp.mail.yahoo.com"); //if using DNS
//smtp_set_server_addr("8.8.8.8"); //if using IP address
// set both username and password as NULL if no authentication needed
smtp_set_auth("-------","--------);
smtp_set_server_port(465);
smtp_send_mail(emailFrom, emailTo, emailSubject, emailMessage, mySMTPresult,
some_argument);
} //sendAnEmail
and this is my handler function for SMTP
//this function is called when SMTP wants to tell us something
void mySMTPresult(void *arg, u8_t smtp_result, u16_t srv_err, err_t err)
{
printf("mail (%p) sent with results: %s, 0x%04x, 0x%08x\n", arg, smtp_result_str(smtp_result), srv_err,err);
} //mySMTPresult
Then when i run the program the Lwip Debugger prints this message:
+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags -+-+-+-+-+-+-+-+-+-+-+-+-+-+
tcp_receive: received FIN.
smtp_tcp_recv: connection closed by remote host
mail (00000000) sent with results: SMTP_RESULT_ERR_CLOSED, 0x0000, 0x00000000
This means that the function smtp_send_email() didn't return any error but message didn't send (i don't receive any email from destination email).
There is someone who knows what i do wrong?
Best regards
Mario
2019-02-03 07:57 AM
Does this method work on a PC implemented with Berkeley Sockets? Does the SMTP server permit this type of connection, or is it blocked to protect against spamming, etc? Many expect a secure connection where username and password are used.
Try using your own SMTP server
2019-02-03 08:05 AM
Yes i suppose that there are security issues with the server. I'am searching for it. Im gonna create a SMTP server after that. Ok thanks a lot!
2019-02-03 09:06 AM
If you have a business, use the internal server.
If within an ISP domain, use the ISP's SMTP with your own credentials and the fact you're within their own walled garden / IP range. ie recognizing your Cable Modem IP/MAC address as one served by them.
2020-03-14 12:52 PM
Excuse me for returning to this topic after one year. I would like to know if you could send an email via SMTP from the NUCLEO-H743ZI?
You could use for development the free SMTP server emulator for a desktop computer, as demonstrated in this video: https://youtu.be/xRXi1N5MR_U
It takes only couple of minutes to get this program running on a desktop computer with any OS. So one can test the code without worrying about the spam issue of the real SMTP servers. Basically it is seen immediately if the email message was sent successfully or not.
With the MCU NUCLEO-F767ZI the SMTP code works fine, as you may see in the video. Could you, please, let me know about your experience with the SMTP on the NUCLEO-H743ZI?