12 Replies Latest reply on Jul 2, 2015 8:37 AM by arun_kumar

    How to send an email using Galileo board?

    Daniel_F11X

      I need to use the Galileo board to send emails. I found the following code which initiates the Ethernet port:

      #include <SPI.h>
      #include <Ethernet.h>

      // the media access control (ethernet hardware) address for the shield:
      byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
      //the IP address for the shield:

      void setup()
      {
         Ethernet.begin(mac);
      }

      I have a couple questions:
      -How can I find what the Galileo board's MAC address is?
        • 1. Re: How to send an email using Galileo board?
          flummer

          Hi Daniel,

           

          I haven't tried exactly this, but as I understand the structure of this board, the underlaying Linux will handle all the ethernet, MAC addresses, etc. and to send an e-mail, you could simply make a system("..."); call to something like sendmail (sendmail might not be part of the standard images, but should be easy to install if not).

           

          I know it's a somewhat different way looking at it, but that's the way I would start exploring on this board.

           

          Just my 5 cents,

           

          /Thomas

          • 2. Re: How to send an email using Galileo board?
            arduino_4_life

            Daniel_F11X, there's a few options available to you.

            You can try out this Arduino Email sketch-

            Arduino Playground - Email

            haven't tried it myself, just did a quick google search (which, by the way, is always a good place to start!)

             

            Or, the SD bootable image contains Python 2.7, so you could get an Ethernet cable and connect to the board using the method detailed here;

            https://communities.intel.com/message/208564#208564

             

            https://pypi.python.org/pypi/mailer

            create your python sketch (you could use the 'mailer' module), then upload an arduino sketch which executes the python script

            system("/home/root/my_script.py");

             

            Message was edited by: Erik Nyquist

            1 of 1 people found this helpful
            • 3. Re: How to send an email using Galileo board?
              arduino_4_life

              Just a quick update- one more option, which will work out-of-the-box without installing additional software, is to telnet into an SMTP server. You could even write a shell script to do this for you, which you could execute from an Arduino sketch.

              How to Telnet to an SMTP Server (with Examples)

              • 4. Re: How to send an email using Galileo board?
                Clayton Hofrock

                The MAC address on my Galileo is on the bottom side of the board, on the mPCIe connector. Kind of a confusing place to put it, but it is there.

                 

                As was previously mentioned, you don't really need the MAC address, anyone will do, as long as it does not conflict with other devices on your network.

                 

                You might want to start with the Ethernet examples in the IDE.

                     File ->Examples->Ethernet (try the TwitterClient or WebClient)

                 

                These will help to verify that the cable and connection to the internet are good. Then you can move on to other examples you can find on the web. :-)

                1 of 1 people found this helpful
                • 5. Re: How to send an email using Galileo board?
                  jhmurry_Intel

                  Here is another code example I just got working. It uses an Arduino sketch that makes a system call to a python script to send email using gmail account.

                   

                  1) Create python script (email.py). Change your email account and password, etc of course...

                  import smtplib

                  fromaddr = 'myemail@gmail.com'

                  toaddrs  = 'toemail@gmail.com'

                  msg = "\r\n".join([

                    "From: myemail@gmail.com",

                    "To: toemail@gmail.com",

                    "Subject: Alert!",

                    "",

                    "Something happened"

                    ])

                   

                   

                  username = 'myemail@gmail.com'

                  password = 'mypassword'

                  server = smtplib.SMTP('smtp.gmail.com:587')

                  server.ehlo()

                  server.starttls()

                  server.login(username,password)

                  server.sendmail(fromaddr, toaddrs, msg)

                  server.quit()

                   

                   

                   

                  2) In your arduino sketch, call this below and update the path if you store it elsewhere

                  system("python /media/realroot/email.py");

                  • 6. Re: How to send an email using Galileo board?
                    krish_22

                    I have tried this script It is working fine in my PC

                    but it is not working in in tel galileo board.

                     

                    error i have mentioned below

                    ============================================================

                    Screenshot from 2014-09-19 12:09:09.png

                    ==============================================================================

                     

                    please help me to solve this

                    • 7. Re: How to send an email using Galileo board?
                      onzverge

                      Thanks, works just fine.

                      One thing I noticed don't name script email.py it will conflict with Python library which has file with same name and script. and will generate AttributError.

                      root@clanton:~# python email.py

                      Traceback (most recent call last):

                      File "sendemail.py", line 1, in <module> import smtplib

                      File "/usr/lib/python2.7/smtplib.py", line 46, in <module> import email.utils

                        File "/home/root/email.py", line 29, in <module>

                      AttributeError: 'module' object has no attribute 'SMTP'


                      Use whatever.py


                       

                      • 8. Re: How to send an email using Galileo board?
                        josesacerio

                        Hello jhmurry

                         

                        I have tried your example Python script both in the Galileo and in my Ubuntu 14 setup and could not get it to work in either platform. The conversation with the server is as follows:

                         

                        root@quark015871:~# python mailer.py

                        send: 'ehlo [192.168.1.66]\r\n'

                        reply: '250-mx.google.com at your service, [23.116.176.98]\r\n'

                        reply: '250-SIZE 35882577\r\n'

                        reply: '250-8BITMIME\r\n'

                        reply: '250-STARTTLS\r\n'

                        reply: '250-ENHANCEDSTATUSCODES\r\n'

                        reply: '250-PIPELINING\r\n'

                        reply: '250-CHUNKING\r\n'

                        reply: '250 SMTPUTF8\r\n'

                        reply: retcode (250); Msg: mx.google.com at your service, [23.116.176.98]

                        SIZE 35882577

                        8BITMIME

                        STARTTLS

                        ENHANCEDSTATUSCODES

                        PIPELINING

                        CHUNKING

                        SMTPUTF8

                        send: 'STARTTLS\r\n'

                        reply: '220 2.0.0 Ready to start TLS\r\n'

                        reply: retcode (220); Msg: 2.0.0 Ready to start TLS

                        send: 'ehlo [192.168.1.66]\r\n'

                        reply: '250-mx.google.com at your service, [23.116.176.98]\r\n'

                        reply: '250-SIZE 35882577\r\n'

                        reply: '250-8BITMIME\r\n'

                        reply: '250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER\r\n'

                        reply: '250-ENHANCEDSTATUSCODES\r\n'

                        reply: '250-PIPELINING\r\n'

                        reply: '250-CHUNKING\r\n'

                        reply: '250 SMTPUTF8\r\n'

                        reply: retcode (250); Msg: mx.google.com at your service, [23.116.176.98]

                        SIZE 35882577

                        8BITMIME

                        AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER

                        ENHANCEDSTATUSCODES

                        PIPELINING

                        CHUNKING

                        SMTPUTF8

                        send: 'AUTH PLAIN AGpvc2VzYWNlcmlvQGdtYWlsLmNvbQBHMTk0Nm9vZw==\r\n'

                        reply: '534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvq_\r\n'

                        reply: '534-5.7.14 mbPvULgffIK2Y9NoN9_zbPAAUJVwRkMnyhWNKa2-8tLTbeC9LcM_tutdCAccvVQXG0ZV_B\r\n'

                        reply: '534-5.7.14 LdlQ43O8gRyJese_5bNpk7XNsM6MQlRjBoicv0ASqmej-g-eKV-11122sbIqSL1DSln4wG\r\n'

                        reply: '534-5.7.14 xNT6usiccsMJ8mpysvHtAePbhSljfU-swqoA_TJgR_dslsxuCP4HqTp1OrEMuIKzcV6Iqx\r\n'

                        reply: '534-5.7.14 2mgNozQ> Please log in via your web browser and then try again.\r\n'

                        reply: '534-5.7.14 Learn more at\r\n'

                        reply: '534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 f71sm2495719yha.42 - gsmtp\r\n'

                        reply: retcode (534); Msg: 5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvq_

                        5.7.14 mbPvULgffIK2Y9NoN9_zbPAAUJVwRkMnyhWNKa2-8tLTbeC9LcM_tutdCAccvVQXG0ZV_B

                        5.7.14 LdlQ43O8gRyJese_5bNpk7XNsM6MQlRjBoicv0ASqmej-g-eKV-11122sbIqSL1DSln4wG

                        5.7.14 xNT6usiccsMJ8mpysvHtAePbhSljfU-swqoA_TJgR_dslsxuCP4HqTp1OrEMuIKzcV6Iqx

                        5.7.14 2mgNozQ> Please log in via your web browser and then try again.

                        5.7.14 Learn more at

                        5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 f71sm2495719yha.42 - gsmtp

                        Traceback (most recent call last):

                          File "mailer.py", line 22, in <module>

                            server.login(username, password)

                          File "/usr/lib/python2.7/smtplib.py", line 620, in login

                            raise SMTPAuthenticationError(code, resp)

                        smtplib.SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvq_\n5.7.14 mbPvULgffIK2Y9NoN9_zbPAAUJVwRkMnyhWNKa2-8tLTbeC9LcM_tutdCAccvVQXG0ZV_B\n5.7.14 LdlQ43O8gRyJese_5bNpk7XNsM6MQlRjBoicv0ASqmej-g-eKV-11122sbIqSL1DSln4wG\n5.7.14 xNT6usiccsMJ8mpysvHtAePbhSljfU-swqoA_TJgR_dslsxuCP4HqTp1OrEMuIKzcV6Iqx\n5.7.14 2mgNozQ> Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 f71sm2495719yha.42 - gsmtp')

                         

                        The account is valid and I can log in through my web browser.

                         

                        I also have the same situation if trying to connect using TELNET.

                         

                        Is this a problem with google only? I really would like to send emails from my Galileo.

                         

                        Thanks for your help.

                         

                        Jose Sacerio

                        • 9. Re: How to send an email using Galileo board?
                          jhmurry_Intel

                          I tried the original code I had on Galileo1 and Galileo 2. It worked on both. Then I remembered a problem I had early on with this code --- My code example ONLY works to login with a gmail account. If you try a Hotmail.com type of account for example it fails with the error joseacerio got. You may want to create an extra account in gmail to use with the methods I described.

                          • 10. Re: How to send an email using Galileo board?
                            josesacerio

                            jhmurry:

                             

                            I used my gmail account and password and it still did not work. The response I posted is teh response I get when I use my gmai; account and password.

                            • 12. Re: How to send an email using Galileo board?
                              arun_kumar

                              For Hotmail account you need to change the python script for hotmail SMTP server as follows:

                              server = smtlib.SMTP('smtp.live.com',465)

                              *port can be 25 or 465 for hotmail server.

                              And that's all! All you need now is give your account name and password in the script.

                              For further on this :

                              SMTP – Simple Mail Transfer Protocol | innovate ideate create