English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang Email

To send emails using Erlang, you need to use the tools fromgithubavailable software packages. The github link is-https: //github.com/Vagabond/gen_smtp

This link containssmtp utilityIt can be used to send emails from Erlang applications. Please follow the following steps to be able to send emails from Erlang

Step 1erl filesfrom the downloadgithub siteThese files should be downloaded tohelloworld.erlthe directory where the application is located.

Step 2−Use compilationsmtp related filesAll the contents listed belowerlc commandYou need to compile the following files.

  • smtp_util

  • gen_smtp_client

  • gen_smtp_server

  • gen_smtp_server_session

  • binstr

  • gen_smtp_application

  • socket

Step 3 −You can write the following code to send an email using smtp.

Online Examples

-module(helloworld). 
-export([start/0}). 
start() -> 
   gen_smtp_client:send({"[email protected]", ["[email protected]"], "Subject: testing"},
   
   [{relay, "smtp.gmail.com"}, {ssl, true}, {username, "[email protected]"}, 
      {password, "senderpassword"}).

The following points should be noted about the above program

  • The smtp function above is used with the smtp server provided by google.

  • Since we are using secure smtp to send, we will specify the ssl parameter as true.

  • You need to specify the relay assmtp.gmail.com.

  • You need to mention a username and password that can send emails.

After configuring all the above settings and executing the program, the recipient will successfully receive an email.