3

How can one handle email related communications pragmatically in Erlang/OTP? Using bash, python or Perl scripts, its possible for one to send out emails. However, in Erlang, i have not yet found an Application or built in function dedicated to sending and/or receiving emails on behalf of other applications.
In yaws, there is a mail application located in the applications path of the web server.However, on the yaws home page, there is no documentation dedicated to this application. In Nitrogen Web framework, i have found nothing yet useful as far as email protocols are concerned.
If any one knows of a library which i can use for sending and/or receiving mails pragmatically, could please direct me. Also there could be unofficial implementations as well that i do not know of. thanks, in advance

Muzaaya Joshua
  • 7,736
  • 3
  • 47
  • 86
  • You accept an answer for the questions that you have asked. You click on the symbol close to the votes on the answer to accept it. – Jonas May 13 '11 at 09:56

2 Answers2

3

I've been successfully using smtp_fsm.erl for sending emails (not exactly this version, but this one is publicly accessible).

Quick search showed some other smtp- and email-related packages, but I don't have experience with any of these.

alavrik
  • 2,151
  • 12
  • 16
1

If you want to send emails with Erlang, you should take a look at the transactional email service AlphaMail.

Here is an example of how to send an email with the AlphaMail module for Erlang:

Service = alphamail:email_service("YOUR-ACCOUNT-API-TOKEN-HERE").
Payload = alphamail:message_payload(
    2,                                                                          % Project id
    alphamail:email_contact(<<"Sender Name">>, <<"from@example.com">>),         % Sender
    alphamail:email_contact(<<"Joe E. Receiver">>, <<"to@example.org">>, 1234), % Receiver (with receiver id)
    % Any JSON serializable payload data
    [
        {"userId", 1234},
        {"name", {struct, [
            {"first", "Joe"},
            {"last", "E. Receiver"},
        ]}},
        {"dateOfBirth", 1989}
    ]
).
alphamail:queue(Service, Payload).

And as your HTML/Comlang template:

<html>
    <body>
        <b>Name:</b> <# payload.name.first " " payload.name.last #><br>
        <b>Date of Birth:</b> <# payload.dateOfBirth #><br>

        <# if (payload.userId != null) { #>
            <a href="/sign-up">Sign Up Free!</a>
        <# } else { #>
            <a href="/login?id=<# payload.userId #>">Sign In</a>
        <# } #>
    </body>
</html>

Disclosure: I'm one of the developers behind AlphaMail