Sending email using SMTP

Hi, I’m testing the SMTP class found on codeshare to send an email(https://www.ghielectronics.com/community/codeshare/entry/327), but I have some problems:

I connect to internet and in the Network_Up function:

   void wifiRS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
            {
                Debug.Print("Network up");

                SmtpClient mySmtp;

                mySmtp = new SmtpClient("smtp.gmx.com", 25);

                mySmtp.Send("myemail@gmx.com", "myemail@gmx.com", "wow", "woow", true, "myemail@gmx.com", "my pass");
                Debug.Print("Email sent");
            }

I’m using gmx email because it does not require SSL
Debugging I’ve got the first response=250(auth ok), then is 530 and then 500, so it does not work properly
Finally I’ve got an exception:

#### Exception System.ArgumentNullException - 0x00000000 (1) ####
    #### Message: 
    #### System.Int16::Parse [IP: 0006] ####
    #### Provaemail.SmtpClient::Send [IP: 0094] ####
    #### Provaemail.Program::wifiRS21_NetworkUp [IP: 0028] ####
    #### Gadgeteer.Modules.Module+NetworkModule::OnNetworkEvent [IP: 0049] ####
    #### System.Reflection.MethodBase::Invoke [IP: 0000] ####
    #### Gadgeteer.Program::DoOperation [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 001d] ####
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Error invoking method "Gadgeteer.Modules.Module+NetworkModule" (check arguments to Program.BeginInvoke are correct)

Do you have any advise?
Thank you

Actually nearly all e-mail server require ssl or tls secured transmission and authentication . The driver from Codeshare doesn’t provide that. In another Codeshare project I used Sparkpost to send e-mails but some days ago they posted that it is not longer free of charge for low quantities.

Oops: Just saw that the provider you selected doesn’t require ssl. :slight_smile:

Response 530 could be an authentication failure message. You might need to debug more to understand it.

Google search for smtp error message 530 shows that it means access denied.
A possible approach to find the reason could be porting the NETMF SMTP Class to a PC and watch the network traffic with e.g. wireshark and compare the network traffic generated by the NETMF Class with the network traffic of a regular PC e-mail client which successfully works with the gmx server.
I would be interested to find an e-mail provider which doesn’t require ssl too. To evtl. set up the application on my side, which mainboard are you using?

I’m using the Fez Spider II
The username and password are surely correct, maybe tomorrow I will test another email provider or use wireshark as you said (which ip address do I have to monitor? I connect the Spider II using the wifi but monitoring that ip gives nothing, while if I set the PC ip a lot of stuff appear)

Hi,
Seems that gmx.com doesn’t support anymore non-SSL connections for years…
(gmx smtp server problem or https://www.dataloggerinc.com/resource-article/non-ssl-smtp-servers-use-datataker-devices/)

HTH

Wireshark won’t see your device because it will be through an effective switch in the router. You could try Wireshark in promiscuous mode but I doubt it will work.

The only way to see the data is with a network HUB and connecting the Spider via hardwired Ethernet instead.

Thank you, as said in the last post of the first link you sent, I created a smtp2go account with gmx username and password, and now it gives me 503 error.
I tested the configuration adding an account to gmail, using gmx email and password and smtp2go server and it worked, I can send email. So the system works, but the code gives me error, so maybe there’s an error in the smtp_class? But this user said it worked using another webemail https://www.ghielectronics.com/community/forum/topic?id=5426&page=3#msg154260

I ment run The Code on The PC, not The Spider

Hi,
You can send/type all SMTP commands with telnet which gives you a chance to determine which command generates the error.

Below is a link to some code I tested with links is some good references. I hope it helps;

I tested with telnet, and everything is ok, I received the email

EDIT. I made it, there was an error on line 67-> HELO instead of EHLO, now it works, thank you to everybody
I updated the codeshare class with only this modification

1 Like