What is the best and most convinient way to send emails using Phoenix framework?
blastula allows you to create and send e-mails using R. It works similarly to the Shiny package, but instead of writing R code to create an interactive application, you write R code to create an HTML e-mail that can be rendered across a wide variety of e-mail providers.
You can't send emails using JavaScript code alone due to lack of support for server sockets. For this, you need a server-side language that talks to the SMTP server. You can use JS in conjunction with a server script that will send emails from the browser based on your requests.
For any company that currently uses Ruby on Rails, Phoenix Framework should be on your radar, because it adds considerable performance gains. To top that off, Phoenix makes it incredibly fast to build web applications.
The best way I've found is to use the mailman package. For sending test emails I was using my gmail account using the following config for mailman
->
def config do
%Mailman.Context{
config: %Mailman.SmtpConfig{ relay: "smtp.gmail.com",
port: 587,
username: "[email protected]",
password: "mypassword",
tls: :always },
composer: %Mailman.EexComposeConfig{}
}
end
and for the email content I was using the following:
def testing_email do
%Mailman.Email{
subject: "Hello Mailman!",
from: "[email protected]",
to: ["[email protected]"],
text: "Hello Mate",
html: Phoenix.View.render_to_string(MyApp.PageView,"index.html", foo: "bar")
}
end
and then you just do ->
1) email = MyApp.Mailer.deliver testing_email
2) Task.await(email)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With