Work with emails (POP3, IMAP, SMTP etc) in Erlang?

How can I handle email related messages pragmatically in Erlang / OTP? Using bash, python, or Perl scripts, you can send emails. However, in Erlang I have not yet found an application or a built-in function designed to send and / or receive letters on behalf of other applications.
The yaws have a mail application, located in the path of the Web application server. However, on yaws, there is no documentation dedicated to this application. In Nitrogen Web Infrastructure , I did not find anything useful regarding email protocols.
If anyone knows a library that I can use to send and / or receive emails pragmatically, I can direct me. There may also be unofficial implementations that I do not know. thanks in advance

+3
source share
2 answers

I have successfully used smtp_fsm.erl to send emails (not this version, but this one is public).

A quick search revealed some other smtp and email related packages, but I have no experience with them.

+2
source

Erlang, AlphaMail.

, AlphaMail 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).

HTML/Comlang:

<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>

: AlphaMail

+1

All Articles