AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_netxduo_smtp_client.c
void    demo_client_thread_entry(ULONG info)
{

UINT        status;
UINT        error_counter = 0;
NXD_ADDRESS server_ip_address;

    NX_PARAMETER_NOT_USED(info);

    tx_thread_sleep(NX_IP_PERIODIC_RATE);

    /* Set up the server IP address. */
    server_ip_address.nxd_ip_version = NX_IP_VERSION_V4;
    server_ip_address.nxd_ip_address.v4 = SERVER_IP_ADDRESS;

    /* The demo client username and password is the authentication 
       data used when the server attempts to authentication the client. */

    status =  nxd_smtp_client_create(&demo_client, &client_ip, &client_packet_pool,
                                     USERNAME, 
                                     PASSWORD,
                                     FROM_ADDRESS,
                                     LOCAL_DOMAIN, CLIENT_AUTHENTICATION_TYPE, 
                                     &server_ip_address, SERVER_PORT);

    if (status != NX_SUCCESS)
    {
        printf("Error creating the client. Status: 0x%x.\n\r", status);
        return;
    }

    /* Create a mail instance with the above text message and recipient info. */
    status =  nx_smtp_mail_send(&demo_client, RECIPIENT_ADDRESS, NX_SMTP_MAIL_PRIORITY_NORMAL, 
                                SUBJECT_LINE, MAIL_BODY, sizeof(MAIL_BODY) - 1);

    /* Check for errors. */
    if (status != NX_SUCCESS)
    {
        
        /* Mail item was not sent. Note that we need not delete the client. The error status may be a failed
           authentication check or a broken connection.  We can simply call nx_smtp_mail_send
           again.  */
        
        error_counter++;
    }

    /* Release resources used by client. Note that the transmit packet
       pool must be deleted by the application if it no longer has use for it.*/
    status = nx_smtp_client_delete(&demo_client);

    /* Check for errors. */
    if (status != NX_SUCCESS)
    {
        error_counter++;
    }

    return;
}
/* Define the smtp application thread task.   */
Define the smtp application thread task.
Define the smtp application thread task .
void    demo_client_thread_entry(ULONG info)
{
UINT        status;
UINT        error_counter = 0;
NXD_ADDRESS server_ip_address;
    NX_PARAMETER_NOT_USED(info);
    tx_thread_sleep(NX_IP_PERIODIC_RATE);
    server_ip_address.nxd_ip_version = NX_IP_VERSION_V4;
    server_ip_address.nxd_ip_address.v4 = SERVER_IP_ADDRESS;
    status =  nxd_smtp_client_create(&demo_client, &client_ip, &client_packet_pool,
                                     USERNAME, 
                                     PASSWORD,
                                     FROM_ADDRESS,
                                     LOCAL_DOMAIN, CLIENT_AUTHENTICATION_TYPE, 
                                     &server_ip_address, SERVER_PORT);
    if (status != NX_SUCCESS)
    {
        printf("Error creating the client. Status: 0x%x.\n\r", status);
        return;
    }
    status =  nx_smtp_mail_send(&demo_client, RECIPIENT_ADDRESS, NX_SMTP_MAIL_PRIORITY_NORMAL, 
                                SUBJECT_LINE, MAIL_BODY, sizeof(MAIL_BODY) - 1);
    if (status != NX_SUCCESS)
    {
        error_counter++;
    }
    status = nx_smtp_client_delete(&demo_client);
    if (status != NX_SUCCESS)
    {
        error_counter++;
    }
    return;
}
void demo_client_thread_entry ( ULONG info ) { UINT status ; UINT error_counter = 0 ; NXD_ADDRESS server_ip_address ; NX_PARAMETER_NOT_USED ( info ) ; tx_thread_sleep ( NX_IP_PERIODIC_RATE ) ; server_ip_address . nxd_ip_version = NX_IP_VERSION_V4 ; server_ip_address . nxd_ip_address . v4 = SERVER_IP_ADDRESS ; status = nxd_smtp_client_create ( & demo_client , & client_ip , & client_packet_pool , USERNAME , PASSWORD , FROM_ADDRESS , LOCAL_DOMAIN , CLIENT_AUTHENTICATION_TYPE , & server_ip_address , SERVER_PORT ) ; if ( status != NX_SUCCESS ) { printf ( " \n \r " , status ) ; return ; } status = nx_smtp_mail_send ( & demo_client , RECIPIENT_ADDRESS , NX_SMTP_MAIL_PRIORITY_NORMAL , SUBJECT_LINE , MAIL_BODY , sizeof ( MAIL_BODY ) - 1 ) ; if ( status != NX_SUCCESS ) { error_counter ++ ; } status = nx_smtp_client_delete ( & demo_client ) ; if ( status != NX_SUCCESS ) { error_counter ++ ; } return ; }
Define the smtp application thread task.
Define the smtp application thread task .
/* Set up the server IP address. */ /* The demo client username and password is the authentication 
       data used when the server attempts to authentication the client. */ /* Create a mail instance with the above text message and recipient info. */ /* Check for errors. */ /* Mail item was not sent. Note that we need not delete the client. The error status may be a failed
           authentication check or a broken connection.  We can simply call nx_smtp_mail_send
           again.  */ /* Release resources used by client. Note that the transmit packet
       pool must be deleted by the application if it no longer has use for it.*/ /* Check for errors. */