Sending a Secure SMTP Email

Set Up the Email and SMTP Variables

The first step is to set the email and SMTP variables with values depending on your SMTP email account.

Gecko OS Commands Description
set email.name_address your@email.address set email.smtp.username your_user_name set email.smtp.password your_password set email.smtp.host your_smtp_host set email.smtp.port your_smtp_host_port Specify your email address Specify your user name. This may be same as your email address Specify your SMTP password Specify the SMTP host via which you send email Specify the SMTP host port. This is typically 587 for secure SMTP

For example, if your email is fred@gmail.com :

set email.name_address  fred@gmail.com
set email.smtp.username  fred@gmail.com
set email.smtp.password s3cr3tFredword
set email.smtp.host  smtp.gmail.com
set email.smtp.port 587

Set Maximum TLS version

This step is necessary only if the SMTP server requires it. You may need to set a maximum TLS version with the network.tls.version variable. For example:

set network.tls.version 10

Set the CA Certificate for your Device

You may require a TLS certificate for your device.

Obtain the Certificate

Obtain the certification in .pem format. For a discussion of certificates see the TLS Client app note .

Copy the Certificate to your Device

You can use the file_create command. For example:

file_create fred_ca_cert.pem 1569
-----BEGIN CERTIFICATE-----
d3RlLCBJbm...
...49cOSvkB5iy6
-----END_CERTIFICATE-----

Copy the certificate text from -----BEGIN CERTIFICATE----- to -----END_CERTIFICATE----- .

Alternatively you can use the Silicon Labs Web App Files tab to drag and drop the certificate file.

See Gecko OS Web App, Files Tab .

Set the Network TLS CA Cert

Set the value of the the network.tls.ca_cert to the CA certificate file you have created. For example:

set network.tls.ca_cert fred_ca_cert.pem

Configure Gmail to Support Sending Emails from Gecko OS

In the case of the Google SMTP servers, you need to switch the Google mail Access for less secure apps setting on.

See https://www.google.com/settings/security/lesssecureapps .

Send the Email

To send the email using the command API, use the smtp_send command:

smtp_send <to email address> <email subject> <length of email content>

To send the email using the Native API, use the SMTP API .


Supporting Gecko OS Versions

Change Log

Modified Changes
2019-01-01 Created