Here we'll show you how to send an email via Gmail from your Samsung ARTIK. Imagine all of the notes you can have it send - reminders, alerts, sweet nothings, etc.
This example uses our Google > Gmail > SendEmail Choreo.
1Make sure you have a Temboo account. If you don't already have one, you can register for free.
2If this is the first time using Temboo, you'll need to set up your ARTIK board to find the Temboo libraries. To do so, you'll need to create the file
/etc/ld.so.conf.d. Inside of
temboo.conf, you'll want to copy the line below and paste it into the file:
ldconfig from the command line to add the Temboo library directory to the system library search path.
You’ll also need to get the IP address of your ARTIK board using
ifconfig. The example below shows the results when the ARTIK board is connected to the internet through an ethernet cable. The IP address you'll want to use is listed next to inet.
[root@localhost ~]$ ifconfig eth0: flags=4163
mtu 1500 inet 10.11.6.200 netmask 255.255.255.0 broadcast 10.11.6.255
3Next, we recommend creating a new Gmail account for sending email programmatically - you can do that here. After you've created your new account, you can skip to step 11.
If you'd like to use an existing Gmail account, you'll need to enable 2-Step Verification and generate an App Password for Temboo. Steps 4 - 10 show you how to do that.
4Sign in to your Google Account settings page by clicking on your name or picture in the upper right corner of the screen and then clicking Account.
5Scroll down to the "Signing in" box.
6Click 2-Step Verification. This will bring you to the 2-Step Verification settings page.
7You will then see a step-by-step guide which will guide you through the setup process.
8After you've enabled 2-Step Verification, you'll be prompted to create an App Password.
9In the Select app dropdown menu, choose "Other", and give this app a name (e.g., TembooApp).
10Click "Generate". You'll be given a 16-digit passcode that can be used to access your Google Account from Temboo.
Note: If you wish to authenticate with OAuth credentials, you should use the Google > Gmailv2 Choreos.
11Go to the Google > Gmail > SendEmail Choreo in our Library.
12Turn IoT Mode ON, select your board from the drop down menu.
The IoT Mode switch can be found on each Choreo page in the Temboo Library
13Test out the Choreo from our website and confirm that you can send an email to yourself.
Testing the SendEmail Choreo from our website
14When you've confirmed that the Choreo runs successfully, scroll down to the CODE section then download the auto-generated C code.
15The auto-generated code references the
TembooAccount.h header file, which contains your Temboo account information and network interface details. You'll find the code for this file beneath your generated sketch. Make sure that you keep this file alongside your main C code on your ARTIK device.
16Copy the downloaded zip file to your ARTIK board using
scp. From your computer, go to the directory where the zip file is located and type the command below. Make sure you use the IP address for your board you found using
[root@localhost ~]$ scp sendemail.zip email@example.com:/home
17Now go to the sendemail directory and compile your code and start sending emails from your ARTIK. Run the first command below to compile your code. After compiling has finished and no errors have been reported, run your program using the second command. If you sent the email to yourself, you'll be able to see a new message in your inbox. You've got mail!.
[root@localhost ~]$ gcc -L/opt/iothub/artik/temboo/temboo_artik_library/lib -ltemboo -I/opt/iothub/artik/temboo/temboo_artik_library/include -DUSE_SSL sendemail.c -o sendemail [root@localhost ~]$ ./sendemail
Note: If you get an error about cdefs.h not being found, this could mean your ARTIK board was not shipped with glibc-headers. This can be solved by reinstalling glibc-headers using the command below. After reinstalling glibc-headers, run the two commands above to compile and run your code.
[root@localhost ~]$ yum reinstall glibc-headers
Now that your ARTIK is sending emails, why not check out the other 2000+ Choreos in our Library and start thinking about all the possibilities for your next project.
We're always happy to help. Just email us at firstname.lastname@example.org, and we'll answer your questions.