There’s very good erlang library with email services – erlmail. Unfortunately there’s no support to authorization in it – you can easy add this feature to library by this patch ( erlmail with authorization )
Here’s an example of using erlmail to send e-mail:
send_mail(UserEmail, Data) ->
{ok, Pid} = smtpc:connect(“smtp.server.com”, ?SMTP_PORT),
smtpc:ehlo(Pid, ?SMTP_SERVER),
smtpc:auth(Pid, ?MAIL_LOGIN, ?MAIL_PASSWORD),
smtpc:mail(Pid, ?MAIL_FROM),
smtpc:rcpt(Pid, UserEmail),
smtpc:data(Pid, Data),
smtpc:quit(Pid).
send_mail(UserEmail, MessageSubject, MessageBody) ->
Data = “From:” ++ ?MAIL_FROM ++ “\r\n” ++ “To:” ++ UserEmail ++ “\r\n” ++ “Subject:” ++
MessageSubject ++ “\r\n\r\n” ++ MessageBody,
send_mail(UserEmail, Data ).
test() ->
send_mail(“user@bokov.net”, “this is subject”, “this is message body!”).