Email API using Phoenix

Hi I am new to phoenix,

I have got a requirement to create a API which will recieve some parameters like to,cc,bcc,subject,mailbody,
Then shoot the email.

Please help really urgent,
I am using Elixir 1.10.1 (compiled with Erlang/OTP 21)
phoenix 1.4.12

If your question is related to Phoenix or Nerves, please post it in the Phoenix or Nerves Questions / Help section. Thanks!

Perhaps I’m missing something here but your question seems really vague.
You would probably get better support if you give us more information.

1 Like

Information like what? as i told you before i am new to phoenix. and have really not much idea about it, just a requirement in office to build an API in phoenix that accepts parameters and send email.

Like what code you have so far, how parameters will be submitted, eg as form data or JSON?

Is DB access required?

Etc.

I’m sorry to say but usually when someone asks vague question like this, they are not usually up to task that what was asked of them. These kind of questions sounds like to me that someone is expecting someone else do their homework. How is someone even putting this task for you if you don’t even know Phoenix yet, can you just get more time and study how Phoenix works first? Are you new to Elixir as well? Because if you are then you need to study Elixir first and if you haven’t used functional language before it might take awhile to learn it.

Phoenix has lot of documentation and blog entries at https://www.phoenixframework.org like https://www.phoenixframework.org/blog/sending-email-with-smtp that you could have just googled. There are also books like Programming Phoenix 1.4 that could be helpful.

Deleted my post accidentally and this forum doesn’t allow you to undelete

3 Likes

Hello,

I’d start with

mix phx.new my_mailer --no-ecto

(–no-ecto broadly speaking means you don’t want a database)

then I’d learn how to implement a json API:


(a tutorial discussed in Building a JSON API in Elixir with Phoenix 1.4+)

or https://elixircasts.io/json-api-with-phoenix-1.4 if are more into video;

then would have a look at
https://hexdocs.pm/phoenix_swoosh/Phoenix.Swoosh.html
as a way for sending mail when a valid requests hits the endpoint you have prepared accordingly to your requirements.

… oh, and I’d also put some kind of basic auth in front of it.

Hth.

1 Like

I use Bamboo https://github.com/thoughtbot/bamboo - both for sending via sendgrid and straight up smtp (using a business gmail)

1 Like