Giter VIP home page Giter VIP logo

swoosh's Introduction

Swoosh

hex.pm hex.pm hex.pm github.com

Compose, deliver and test your emails easily in Elixir.

Swoosh comes with many adapters, including SendGrid, Mandrill, Mailgun, Postmark and SMTP. See the full list of adapters below.

The complete documentation for Swoosh is available online at HexDocs.

Requirements

Elixir 1.13+ and Erlang OTP 24+

Getting started

# In your config/config.exs file
config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.Sendgrid,
  api_key: "SG.x.x"
# In your application code
defmodule Sample.Mailer do
  use Swoosh.Mailer, otp_app: :sample
end
defmodule Sample.UserEmail do
  import Swoosh.Email

  def welcome(user) do
    new()
    |> to({user.name, user.email})
    |> from({"Dr B Banner", "[email protected]"})
    |> subject("Hello, Avengers!")
    |> html_body("<h1>Hello #{user.name}</h1>")
    |> text_body("Hello #{user.name}\n")
  end
end
# In an IEx session
email = Sample.UserEmail.welcome(%{name: "Tony Stark", email: "[email protected]"})
Sample.Mailer.deliver(email)
# Or in a Phoenix controller
defmodule Sample.UserController do
  use Phoenix.Controller
  alias Sample.UserEmail
  alias Sample.Mailer

  def create(conn, params) do
    user = create_user!(params)

    UserEmail.welcome(user) |> Mailer.deliver()
  end
end

See Swoosh.Mailer for more configuration options.

Installation

  • Add swoosh to your list of dependencies in mix.exs:

    def deps do
      [{:swoosh, "~> 1.16"}]
    end
  • (Optional-ish) Most adapters (non SMTP ones) use Swoosh.ApiClient to talk to the service provider. Swoosh comes with Swoosh.ApiClient.Hackney configured by default. If you want to use it, you just need to include Hackney as a dependency of your app.

    Swoosh also accepts Finch and Req out-of-the-box. See Swoosh.ApiClient.Finch and Swoosh.ApiClient.Req for details.

    If you need to integrate with another HTTP client, it's easy to define a new API client. Follow the Swoosh.ApiClient behaviour and configure Swoosh to use it:

    config :swoosh, :api_client, MyApp.ApiClient

    But if you don't need Swoosh.ApiClient, you can disable it by setting the value to false:

    config :swoosh, :api_client, false

    This is the case when you are using Swoosh.Adapters.Local, Swoosh.Adapters.Test and adapters that are SMTP based, that don't require an API client.

  • (Optional) If you are using Swoosh.Adapters.SMTP, Swoosh.Adapters.Sendmail or Swoosh.Adapters.AmazonSES, you also need to add gen_smtp to your dependencies:

    def deps do
      [
        {:swoosh, "~> 1.6"},
        {:gen_smtp, "~> 1.0"}
      ]
    end

Adapters

Swoosh supports the most popular transactional email providers out of the box and also has an SMTP adapter. Below is the list of the adapters currently included:

Provider Swoosh adapter Remarks
SMTP Swoosh.Adapters.SMTP
Mua Swoosh.Adapters.Mua SMTP alternative
SendGrid Swoosh.Adapters.Sendgrid
Brevo Swoosh.Adapters.Brevo Sendinblue
Sendmail Swoosh.Adapters.Sendmail
Mandrill Swoosh.Adapters.Mandrill
Mailgun Swoosh.Adapters.Mailgun
Mailjet Swoosh.Adapters.Mailjet
MsGraph Swoosh.Adapters.MsGraph
Postmark Swoosh.Adapters.Postmark
SparkPost Swoosh.Adapters.SparkPost
Amazon SES Swoosh.Adapters.AmazonSES
Amazon SES Swoosh.Adapters.ExAwsAmazonSES
Dyn Swoosh.Adapters.Dyn
Scaleway Swoosh.Adapters.Scaleway
SocketLabs Swoosh.Adapters.SocketLabs
Gmail Swoosh.Adapters.Gmail
MailPace Swoosh.Adapters.MailPace OhMySMTP
SMTP2GO Swoosh.Adapters.SMTP2GO
ProtonBridge Swoosh.Adapters.ProtonBridge
Mailtrap Swoosh.Adapters.Mailtrap
ZeptoMail Swoosh.Adapters.ZeptoMail

Configure which adapter you want to use by updating your config/config.exs file:

config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.SMTP
  # adapter config (api keys, etc.)

Check the documentation of the adapter you want to use for more specific configurations and instructions.

Adding new adapters is super easy and we are definitely looking for contributions on that front. Get in touch if you want to help!

Recipient

The Recipient Protocol enables you to easily make your structs compatible with Swoosh functions.

defmodule MyUser do
  @derive {Swoosh.Email.Recipient, name: :name, address: :email}
  defstruct [:name, :email, :other_props]
end

Now you can directly pass %MyUser{} to from, to, cc, bcc, etc. See Swoosh.Email.Recipient for more details.

Async Emails

Swoosh does not make any special arrangements for sending emails in a non-blocking manner. Opposite to some stacks, sending emails, talking to third party apps, etc in Elixir do not block or interfere with other requests, so you should resort to async emails only when necessary.

One simple way to deliver emails asynchronously is by leveraging Elixir's standard library. First add a Task supervisor to your application root, usually at lib/my_app/application.ex:

def start(_, _) do
  children = [
    ...,
    # Before the endpoint
    {Task.Supervisor, name: MyApp.AsyncEmailSupervisor},
    MyApp.Endpoint
  ]

  Supervisor.start_link(children, strategy: :one_for_one)
end

Now, whenever you want to send an email:

Task.Supervisor.start_child(MyApp.AsyncEmailSupervisor, fn ->
  %{name: "Tony Stark", email: "[email protected]"}
  |> Sample.UserEmail.welcome()
  |> Sample.Mailer.deliver()
end)

Please take a look at the official docs for Task and Task.Supervisor for further options.

One of the downsides of sending email asynchronously is that failures won't be reported to the user, who won't have an opportunity to try again immediately, and tasks by default do not retry on errors. Therefore, if the email must be delivered asynchronously, a safer solution would be to use a queue or job system. Elixir's ecosystem has many job queue libraries.

  • Oban is the current community favourite. It uses PostgreSQL for storage and coordination.
  • Exq uses Redis and is compatible with Resque / Sidekiq.

Attachments

You can attach files to your email using the Swoosh.Email.attachment/2 function. Just give the path of your file as an argument and we will do the rest. It also works with a %Plug.Upload{} struct, or a %Swoosh.Attachment{} struct, which can be constructed using Swoosh.Attachment.new detailed here in the docs.

All built-in adapters have support for attachments.

new()
|> to("[email protected]")
|> from({"Jarvis", "[email protected]"})
|> subject("Invoice May")
|> text_body("Here is the invoice for your superhero services in May.")
|> attachment("/Users/jarvis/invoice-peter-may.pdf")

Testing

In your config/test.exs file set your mailer's adapter to Swoosh.Adapters.Test so that you can use the assertions provided by Swoosh in Swoosh.TestAssertions module.

defmodule Sample.UserTest do
  use ExUnit.Case, async: true

  import Swoosh.TestAssertions

  test "send email on user signup" do
    # Assuming `create_user` creates a new user then sends out a
    # `Sample.UserEmail.welcome` email
    user = create_user(%{username: "ironman", email: "[email protected]"})
    assert_email_sent Sample.UserEmail.welcome(user)
  end
end

Mailbox preview in the browser

Swoosh ships with a Plug that allows you to preview the emails in the local (in-memory) mailbox. It's particularly convenient in development when you want to check what your email will look like while testing the various flows of your application.

For email to reach this mailbox you will need to set your Mailer adapter to Swoosh.Adapters.Local:

# in config/dev.exs
config :sample, MyApp.Mailer,
  adapter: Swoosh.Adapters.Local

In your Phoenix project you can forward directly to the plug without spinning up a separate webserver, like this:

# in web/router.ex
if Mix.env == :dev do
  scope "/dev" do
    pipe_through [:browser]

    forward "/mailbox", Plug.Swoosh.MailboxPreview
  end
end

You can also start a new server if your application does not depends on Phoenix:

# in config/dev.exs
# to run the preview server alongside your app
# which may not have a web interface already
config :swoosh, serve_mailbox: true
# in config/dev.exs
# to change the preview server port (4000 by default)
config :swoosh, serve_mailbox: true, preview_port: 4001

When using serve_mailbox: true make sure to have either plug_cowboy or bandit as a dependency of your app.

{:plug_cowboy, ">= 1.0.0"}
# or
{:bandit, ">= 1.0.0"}

And finally you can also use the following Mix task to start the mailbox preview server independently:

mix swoosh.mailbox.server

Note: the mailbox preview won't display emails being sent from outside its own node. So if you are testing using an IEx session, it's recommended to boot the application in the same session. iex -S mix phx.server or iex -S mix swoosh.mailbox.server will do the trick.

If you are curious, this is how it the mailbox preview looks like:

Plug.Swoosh.MailboxPreview

Note : To show the preview we use the cdn-version of Tailwindcss. If you have set a content-security-policy you may have to add https://cdn.tailwindcss.com to default-src to have the correct make up.

The preview is also available as a JSON endpoint.

curl http://localhost:4000/dev/mailbox/json

Production

Swoosh starts a memory storage process for local adapter by default. Normally it does no harm being left around in production. However, if it is causing problems, or you don't like having it around, it can be disabled like so:

# config/prod.exs
config :swoosh, local: false

Telemetry

The following events are emitted:

  • [:swoosh, :deliver, :start]: occurs when Mailer.deliver/2 begins.
  • [:swoosh, :deliver, :stop]: occurs when Mailer.deliver/2 completes.
  • [:swoosh, :deliver, :exception]: occurs when Mailer.deliver/2 throws an exception.
  • [:swoosh, :deliver_many, :start]: occurs when Mailer.deliver_many/2 begins.
  • [:swoosh, :deliver_many, :stop]: occurs when Mailer.deliver_many/2 completes.
  • [:swoosh, :deliver_many, :exception]: occurs when Mailer.deliver_many/2 throws an exception.

View example in docs

Documentation

Documentation is written into the library, you will find it in the source code, accessible from iex and of course, it all gets published to HexDocs.

Contributing

We are grateful for any contributions. Before you submit an issue or a pull request, remember to:

  • Look at our Contributing guidelines
  • Not use the issue tracker for help or support requests (try StackOverflow, IRC or Slack instead)
  • Do a quick search in the issue tracker to make sure the issues hasn't been reported yet.
  • Look and follow the Code of Conduct. Be nice and have fun!

Running tests

Clone the repo and fetch its dependencies:

git clone https://github.com/swoosh/swoosh.git
cd swoosh
mix deps.get
mix test

Building docs

MIX_ENV=docs mix docs

LICENSE

See LICENSE

swoosh's People

Contributors

adamu avatar adzz avatar ascandella avatar barisbalic avatar cenavarro avatar davec82 avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar florish avatar hermanverschooten avatar josevalim avatar kianmeng avatar lostkobrakai avatar michalmuskala avatar mpran avatar nicksanders avatar princemaple avatar rhnonose avatar ruslandoga avatar sebastianseilund avatar sescobb27 avatar stefanchrobot avatar stevedomin avatar taobojlen avatar theodowling avatar thiamsantos avatar victorsolis avatar wojtekmach avatar zorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swoosh's Issues

Add json endpoint for mailbox preview

When doing end-to-end testing with frontend of features like account registration that involve unique tokens and things like that, it would be useful to have a json version of the mailbox that the tests could query.

I did recently something similar in one of our projects. If you find this idea worth considering I could work on it.

Module doc

For all the modules, even if it's very basic. At least we'll have something to build on.

Support for Erlang 19

Swoosh depends on the gen_smtp package version 0.10.0 which uses, apparently, now old spec format and thus I can't compile it using elixir 1.3.0. I am wondering if we can bump the gen_smtp version to 0.11.0 and release a new minor version, 3.0.1?

Revisit error cases for adapters

I noticed while doing integration testing that our adapters assume a lot about the response from the provider service. Specifically if the mailgun domain is invalid or can't be found, the provider returns a 404 with a standard HTML page, which breaks horribly when we try to Poison.decode!/1 it.

I suspect other providers and errors are better catered for, but we should check, and decide how to handle this in a uniform manner.

18/03 Chat topics

  • Interface of %Swoosh.Email
    • Should reply_to also accept {name, email}
    • Should all methods that take users also accept user, email as well as tuples
    • Where do we put provider options in the struct
  • Implementation of %Swoosh.Email functions, clever but confusing and make docs tricky
  • Should we add a primitive email address validation? i.e. contains one @ and one . ?

Phoenix integration

Do whatever it takes to integrate swoosh with phoenix, such that it can pick up layouts, templates and anything necessary from views.

Mailgun Adapter: ArgumentError :erlang.bit_size(nil)

Using swoosh: 0.3.0 and phoenix_swoosh: 0.1.1.

I am pretty sure this error is being raised because there is something wrong with my config. It is hard to figure out exactly what is missing from the error message.

> MyApp.Emails.forgot_password(%{first_name: "Test", last_name: "User", email: "[email protected]"}, "test") |> MyApp.Mailer.deliver
** (ArgumentError) argument error
             :erlang.bit_size(nil)
    (swoosh) lib/swoosh/adapters/mailgun.ex:33: Swoosh.Adapters.Mailgun.deliver/2

Quick link to the line in question: https://github.com/swoosh/swoosh/blob/v0.3.0/lib/swoosh/adapters/mailgun.ex#L33

Here is the adapter configuration.

> Application.get_env(:myapp, MyApp.Mailer)
[adapter: Swoosh.Adapters.Mailgun,
 api_key: "key-a1a2a2s22d2d2d2d2d2d2",
 domain: "mailgun.myapp.com"]

And the raw sys.config entry just in case this is an issue with strings vs binaries.

[
% ... other config stuff here
{myapp, [
  {'Elixir.MyApp.Mailer',[
    {adapter,'Elixir.Swoosh.Adapters.Mailgun'},
    {api_key,<<"key-a1a2a2s22d2d2d2d2d2d2">>},
    {domain,<<"mailgun.myapp.com">>}]}
]},
]
.

Any ideas why this error is happening?

The code works in development where the swoosh config is defined in config/dev.exs instead of the sys.config file (exrm).

Provide a `deliver_later` function

Curious on the reasoning for not having a potential way to deliver mail asynchronously? I looked for it in the issues but couldn't find anything. Is this an idea to add or would this restrict the logic too much for another user?

optionally passing config as parameter when sending email

Example: Mailgun. It requires you to use the domain you are sending from in API calls. Some sites use more than one domain.

If you have an app that uses several domains, it would be nice if you could pass the domain as part of the parameters to the sending function.

Postmark Adapter

Implement an adapter for sending basic emails through Postmark.

Adapter return value

The Adapter behaviour's function signature allows of a successful return type as :ok | {:ok, term} with no indication of why one or the other. This makes pattern matching a bit cumbersome without knowing the internals of the adapter.

Is there a reason why both are supported? Can this be documented more clearly?

Runtime settings

It seems that at least for the smtp adapter, the env.ex is read once during compilation and those values are compiled in.

Problem being that I'm using System.get_env("SMTP_USERNAME") for example, these values are not available at compile time, but are during runtime (Docker standard behaviour).

This is fine for things like Postgrex and it's database_url setting, or redis configuration, and even mailman - which is what I'm migrating from.

If it's absolutely necessary to keep that behavior for some reason, could there be a deliver method that takes a config (on the mailer and passes that through to the adapter instead of the static configuration)?

Deal with provider accounts in a sane manner

We probably want to have integration tests and API keys available for running tests, the easiest way to do this is to set up a shared account somewhere, somehow, and then we can contact providers and ask for free accounts.

Can't put API key in environment variable

Hi
I'm trying to put the Sendgrid API key in an environment variable rather than hardcoded inside config.exs.

This is what my config looks like:

config :my_app, MyApp.Mailer,
  adapter: Swoosh.Adapters.Sendgrid,
  api_key: System.get_env("SENDGRID_API_KEY")

It looks like the credentials are loaded fine on development with mix run --no-halt but when I run on production mode MIX_ENV=prod the environment variable is not being loaded correctly although I see them on Application.get_all_env(:my_app)
When I replace the get_env with the explicit API key everything works well.

What am I missing here?

Consider loosening your Poison requirements

Proposal

Currently, in mix.exs, you have:

{:poison, "~> 2.1"}

Consider loosening the requirement to also allow version 1.5.x series

{:poison, "~> 1.5 or ~> 2.0"}

Why?

After a casual search for Poison in the swoosh codebase:

https://github.com/swoosh/swoosh/search?utf8=%E2%9C%93&q=Poison

I noticed that swoosh uses neither the defimpl feature of the 1.5.x poison nor the @derive Poison.Encoder of the 2.x series to define it's encoding rules, preferring instead to leave the dirty work to Poison itself.

This means swoosh can probably support both versions of poison, which means, for us pleb end-users, if you could loosen your poison requirement, it would make things a lot easier as a lot of our older libraries depend on the 1.x series of poison.

Mailgun reply_to not working

I've configured email for use with mailgun. The email is sending correctly through the mailgun api, but the reply_to isn't being added. I switched to this library specifically for this feature, so it is important for me that this work. I'll be happy to help troubleshoot/fix this issue.

defmodule NwreccOrg.SendMinisiteEmail do
  import Swoosh.Email
  def proxy(property, params) do
    unless Map.has_key?(params, :email) do
      params = Map.put(params, :email, "[email protected]")
    end

    new
    |> to({ property.name, property.email})
    |> reply_to(params.email)
    |> from("[email protected]")
    |> subject("Email Contact")
    |> text_body(contact_us_text(params))
  end

  defp contact_us_text(params) do
    ....
  end
end

Can't customize SMTP port used by SMTP Adapter

For local development purposes I'm trying to consolidate all email delivery to a locally running Mailhog instance. By default it runs its SMTP server on port 1025. The Swoosh SMTP adapter doesn't seem to be able to customize the port used and always assumes 25.

I looked into how the config is passed to gen_smtp, and it LOOKS like all I need to do is add port: 1025 to my config and it should theoretically work. But I haven't been able to get it to work.

Any ideas?

Mailgun including custom variables

Hello all!

I'm using Swoosh right now with the Mailgun adapter. One of the features in Mailgun is including custom variables in the params of the post request, and the variables will be later included in mailgun event webhooks, and allow us to identify mails using our variables.

More details: https://documentation.mailgun.com/user_manual.html#attaching-data-to-messages

From looking at prepare_body methods, swoosh mailgun adapter doesn't seem to allow including other params like the custom variables (let me know if this is not the case!!). I would like to make pull request to add this functionality in the mailgun adapter. I already read guidelines for contributing but since I have never contributed to open source codes before, I want to check if this is a good/valid feature to add. :) Please let me know if I should go ahead and add codes!

Clean README with examples

Replace the README with something meaningful to users, include some basic examples in lieu of documentation.

DKIM for SMTP adapter

Support DKIM in the SMTP adapter so that user can sign their emails before sending.

Highlight differences between other similar libraries

Hello,

It looks like this library was started after Bamboo was already established. It would be helpful to have a section in the README addressing how this library differs from Bamboo, and why it was necessary to create a separate project. For example, is there a fundamental design objective or approach which differs between the projects? This will make it easier for consuming developers to decide which is right for them.

Thank you!

Support Conform Style Configuration

The macro reads the configuration and sets it to the module attribute @config. Swoosh supports transforming environment variables, but that's only one way of deploying.

bitwalker/conform is another model that overwrites the sys.config based on a configuration file deployed to the server. If the config was read at runtime, instead of compile time then the conform style of deployments could be supported as well.

Not able to send email

Hello, I'm following the docs to set a mailer using SMTP adapter but I'm getting the following error when executing from iex:

Webapp.ReportEmail.welcome() |> Webapp.Mailer.deliver
** (MatchError) no match of right hand side value: []
    (gen_smtp) /home/app/mix_deps/gen_smtp/src/mimemail.erl:1027: :mimemail.dkim_sign/2
    (gen_smtp) /home/app/mix_deps/gen_smtp/src/mimemail.erl:982: :mimemail.dkim_sign_email/3
    (gen_smtp) /home/app/mix_deps/gen_smtp/src/mimemail.erl:115: :mimemail.encode/2
      (swoosh) lib/swoosh/adapters/smtp.ex:40: Swoosh.Adapters.SMTP.deliver/2

Settings implemented:
config/config.exs

config :webapp, Webapp.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.service.com",
  username: "[email protected]",
  password: "mypass", 
  tls: :always,
  auth: :always,
  dkim: [
    s: "default", d: "domain.com",
    private_key: {:pem_plain, "test-key"} #File.read!("priv/keys/domain.private")
  ]

lib/webapp/mailer.ex

defmodule Webapp.Mailer do
  use Swoosh.Mailer, otp_app: :webapp
end

defmodule Webapp.ReportEmail do
  import Swoosh.Email

  def welcome() do
    new
    |> to({"Somebody", "[email protected]"})
    |> from({"Other", "[email protected]"})
    |> subject("Hello, test!")
    |> html_body("Hello you") 
    |> text_body("Hello you\n")
  end
end

Using:
:swoosh, "~> 0.4.0"
gen_smtp: 0.11.0
phoenix, 1.1.6
Elixir (1.3.1)
Ideas please?

Mailgun Adapter not sending parameters, lock hackney to 1.6.5

Mailgun Adapter will throw an error when sending an email telling 'from' parameter is missing, but I send this params

Here are the params we sent:

"from=no-reply%40mydomain.fr....."

Cause

hackney is used within the Mailgun Adapter and seems to duplicate the content-type header as described in this issue benoitc/hackney#388. Mailgun won't understand the body and throw the error 'from' parameter is missing

Temporary Solution

Lock hackney to 1.6.5, this issue was introduced with the 1.6.6 release

Module Swoosh.Adapters.SMTP is not available

I'm having an odd problem:

iex(1)> {:ok, conf} = Application.fetch_env(:email, Email.Mailer)
{:ok,
 [adapter: Swoosh.Adapters.SMTP, relay: {:system, "EMAIL_HOST"},
  username: {:system, "EMAIL_USERNAME"}, password: {:system, "EMAIL_PASSWORD"}]}

iex(2)> Swoosh.Adapters.SMTP.validate_config(conf)
** (UndefinedFunctionError) function Swoosh.Adapters.SMTP.validate_config/1 is undefined (module Swoosh.Adapters.SMTP is not available)
    Swoosh.Adapters.SMTP.validate_config([adapter: Swoosh.Adapters.SMTP, relay: {:system, "EMAIL_HOST"}, username: {:system, "EMAIL_USERNAME"}, password: {:system, "EMAIL_PASSWORD"}])

But other adapters are present:

iex(3)> conf = [adapter: Swoosh.Adapters.Logger]
[adapter: Swoosh.Adapters.Logger]
iex(4)> Swoosh.Adapters.Logger.validate_config(conf)
:ok

Am I doing something really silly here?

Dependency on Cowboy 1.0.0

Hi,
I was playing around with Coherence and it has a dependency on Swoosh. However, the dependencies are not resolved because swoosh has a strict dependence on Cowboy 1.0.0.

Running dependency resolution...

Failed to use "cowboy" (version 1.1.2) because
  phoenix (version 1.2.1) requires ~> 1.0
  plug (version 1.3.0) requires ~> 1.0.1 or ~> 1.1
  swoosh (versions 0.1.0 to 0.5.0) requires ~> 1.0.0
  mix.exs specifies ~> 1.1.2

** (Mix) Hex dependency resolution failed, relax the version requirements of your dependencies or unlock them (by using mix deps.update or mix deps.unlock). If you are unable to resolve the conflicts you can try overriding with {:dependency, "~> 1.0", override: true}

Perhaps it should be ~> 1.0 ?

Mandrill Adapter

Create a working adapter for sending basic emails through Mandrill.

Swoosh for text messages

I really like how swoosh is structured and I'd like to hear your opinion on possibility of extending the use of the library.

I'd like to propose we reuse the main ideas behind swoosh (adapters, local mailbox) and apply them to text messages - many things could be reused. However there are several approaches we could make:

  • add text message handling directly to swoosh
  • make a separate project that would use the same ideas from swoosh
  • create a swoosh-text project initially copying the code that should be reused, and eventually extracting common components into something like swoosh-core.

I don't want to impose anything, but I think it's an interesting idea worth exploring.

Can't preview emails in `Swoosh.Adapters.Local`

Here's my setup:

config.exs:

config :elixir_lang_moscow, ElixirLangMoscow.Mailer,
  adapter: Swoosh.Adapters.Local

router.ex:

  if Mix.env == :dev do
    scope "/dev" do
      pipe_through [:browser]
      forward "/mailbox", Plug.Swoosh.MailboxPreview, [base_path: "/dev/mailbox"]
    end
  end

lib/mailer.ex:

defmodule ElixirLangMoscow.Mailer do
  use Swoosh.Mailer, otp_app: :elixir_lang_moscow
end

Here's what it looks like:
2016-07-25 15 51 23

When sending an email via ElixirLangMoscow.Mailer.deliver/2 it returns something like: {:ok, %{id: "3d96e237f56230a27ba9953688646530"}} and nothing happens.

My env:

Erlang/OTP 19 [erts-8.0.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.3.2)
"phoenix": {:hex, :phoenix, "1.1.6", "7bf19002669c8f692f5a9c8d30dab7b49f3dc56228d5bde92a12fb426b4783c2", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"swoosh": {:hex, :swoosh, "0.4.0", "2e1c90ba80146b4ce79923e7467c0ebf10dc6cf8933f98161fa12dd5ce848928", [:mix], [{:plug, "~> 1.1", [hex: :plug, optional: true]}, {:cowboy, "~> 1.0.0", [hex: :cowboy, optional: true]}, {:gen_smtp, "~> 0.11", [hex: :gen_smtp, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:httpoison, "~> 0.8", [hex: :httpoison, optional: false]}]},

Sending in localhost works but not on the server

I am using the SparkPost adaptor with Coherence (which has built in support for Swoosh). The emails are successfully sent from my laptop in development, and I receive them as expected. But using the same config code on the server does not work. I checked the online app logs which is proxy behind nginx and there are no error messages on the app side or nginx side.

I use the ubuntu firewall (ufw) and turned it off and still it does not work.

Checking the account in SparkPost also shows that the emails are sent from the localhost, but as if SparkPost receives no post request from the server.

Would someone have a clue what could be the issue.

cannot send attachment

Hello

nothing in the docs for attachments, but the field exist in the email record
cannot find a way to specify attachment file

thanks

Better adapter tests

The one we have currently are pretty shallow, we should especially the prepare_body

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.