Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

jmmille's Content

There have been 5 items by jmmille (Search limited from 18-June 23)


By content type

See this member's

Sort by                Order  

#13350 SMTP with .NET Micro Framework

Posted by jmmille on 16 May 2011 - 02:11 PM in Netduino Plus 2 (and Netduino Plus 1)

The added code works fine under emulation and shows the SMTP server responses, however running it on the Netduino Plus, the SOCKET.POLL times out , suggesting that the SMTP server is not sending anything.

Am I missing something here?

Hi, it's been a while since I took a look at this topic. While playing with telnet on my mail server, I noticed I only get responses from the mail server when I send the Helo, mail from and rcpt to commands. The only other response comes after the message is sent, which said something like "Message scheduled for delivery."

Do you happen to be running the function in between the other commands?



#12648 SMTP with .NET Micro Framework

Posted by jmmille on 29 April 2011 - 06:06 PM in Netduino Plus 2 (and Netduino Plus 1)

Ok, with a lot of help from Stefan, this appears to be working without authentication.

HELO localhost -- caused problems. I needed a real domain. I'm using google.com. The domain of the mail server caused issues as well.

I used Stefan's code post above and nothing happened. I had to put some Sleep's in the code because Netduino was sending commands faster than the mail server could respond. Here's what I ended up with. I hope it helps someone.

            static IPAddress mailip = IPAddress.Parse("192.168.1.15");      
      
            Socket smtp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            
            string MailBody = "";
            MailBody += "Subject: Test Email\r\n";
            MailBody += "From: \"Netduino\" <netduino@domain.com>\r\n";
            MailBody += "To: \"My Email\" <email@domain.com\r\n";
            MailBody += "\r\n"; // devider between message headers and message body
            MailBody += "This is just a test!\r\n";
            MailBody += ".\r\n";
            
            Thread.Sleep(500);
            led.Write(true);
            Debug.Print("Connecting...");
            smtp.Connect(new IPEndPoint(mailip, 25));
            
            smtp.Send(Encoding.UTF8.GetBytes("HELO google.com\r\n"));
            Thread.Sleep(100);
            smtp.Send(Encoding.UTF8.GetBytes("MAIL FROM: netduino@domain.com\r\n"));
            Thread.Sleep(100);
            smtp.Send(Encoding.UTF8.GetBytes("RCPT TO: email@domain.com\r\n"));
            Thread.Sleep(100);
            smtp.Send(Encoding.UTF8.GetBytes("DATA\r\n"));
            Thread.Sleep(100);
            smtp.Send(Encoding.UTF8.GetBytes(MailBody));
            Thread.Sleep(100);
            smtp.Send(Encoding.UTF8.GetBytes("QUIT\r\n"));
                       
            smtp.Close();
            Debug.Print("Sent!");
            led.Write(false);



#12642 SMTP with .NET Micro Framework

Posted by jmmille on 29 April 2011 - 02:57 PM in Netduino Plus 2 (and Netduino Plus 1)

string MailData = "";
MailData += "HELO localhost\r\n";
MailData += "MAIL FROM: test@domain.com\r\n";
MailData += "RCPT TO: myemail@domain.com\r\n";
MailData += "DATA\r\n";
MailData += "Subject: Test Email\r\n";
MailData += "From: \"My Name\" <test@domain.com>\r\n";
MailData += "To: \"your name\" <myemail@domain.com\r\n";
MailData += "\r\n"; // devider between message headers and message body
MailData += "This is just a test!\r\n";
MailData += ".\r\n"; // end of message
MailData += "QUIT\r\n";

Debug.Print(MailData);
I can't test this part, but I suppose this should work:
smtp.Connect(new IPEndPoint(mailip, 25));
smtp.Send(Encoding.UTF8.GetBytes(MailData));
smtp.Close();


Ok, so this doesn't seem to work for me. Does anyone know of a way to read what the SMTP server is responding with each line? I'm not even sure if you can read and write on the same socket.

Thanks



#12638 SMTP with .NET Micro Framework

Posted by jmmille on 29 April 2011 - 12:07 PM in Netduino Plus 2 (and Netduino Plus 1)

Let us know if you get something working. I can find another route that does not require authentication.

Yea, I'm not having much luck with sockets either. I tried the following code. It says it works successfully but the email never goes.

Socket smtp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            

            smtp.Connect(new IPEndPoint(mailip, 25));
            smtp.Send(Encoding.UTF8.GetBytes("HELO localhost"));
            smtp.Send(Encoding.UTF8.GetBytes("MAIL FROM: test@domain.com"));
            smtp.Send(Encoding.UTF8.GetBytes("RCPT TO: myemail@domain.com"));
            smtp.Send(Encoding.UTF8.GetBytes("DATA"));
            smtp.Send(Encoding.UTF8.GetBytes("Subject: Test Email"));
            smtp.Send(Encoding.UTF8.GetBytes("This is just a test!"));
            smtp.Send(Encoding.UTF8.GetBytes(" . ")); 
            smtp.Send(Encoding.UTF8.GetBytes("QUIT"));

            smtp.Close();



#12532 SMTP with .NET Micro Framework

Posted by jmmille on 27 April 2011 - 01:18 PM in Netduino Plus 2 (and Netduino Plus 1)

I am having trouble getting the Bansky SMTP to work also, regardless of it not supporting SSL.

It compiles OK, runs OK under emulation, but after uploading it to the N+ it generates non-descript SMTPclientclass Exceptions.

Upon closer examination, it appears that the Netduino is not receiving a response from the SMTP Server, yet the socket connection appears to be succeeding.

Has anyone managed to get this running with their N+?

I was messing around with it yesterday but had the same issue you are. I'm working on the socket method now. I don't need authentication for my particular project.




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.