Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailer failure doesn't show a reasonable error message #74

Open
StephenGrider opened this issue Apr 28, 2016 · 20 comments
Open

Mailer failure doesn't show a reasonable error message #74

StephenGrider opened this issue Apr 28, 2016 · 20 comments

Comments

@StephenGrider
Copy link

StephenGrider commented Apr 28, 2016

Love this project, thanks so much! This may be out of scope of Addict; I'm adding it as an issue to help others who run into it.

Walking through the readme setup guide, I encountered an error when attempting to create an account on the /register route.

Error:

[error] #PID<0.976.0> running Workshop.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /register
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
        (elixir) lib/io.ex:346: IO.chardata_to_string(nil)
        (elixir) lib/path.ex:467: Path.join/2
        (elixir) lib/path.ex:449: Path.join/1
        lib/client.ex:44: Mailgun.Client.send_without_attachments/2
        lib/addict/mailers/mailgun.ex:11: Addict.Mailers.Mailgun.send_email/4
        lib/addict/interactors/register.ex:26: Addict.Interactors.Register.do_register/2
        lib/addict/controller.ex:16: Addict.AddictController.register/2
        lib/addict/controller.ex:1: Addict.AddictController.action/2
        lib/addict/controller.ex:1: Addict.AddictController.phoenix_controller_pipeline/2
        (workshop) lib/phoenix/router.ex:261: Workshop.Router.dispatch/2
        (workshop) web/router.ex:1: Workshop.Router.do_call/2
        (workshop) lib/workshop/endpoint.ex:1: Workshop.Endpoint.phoenix_pipeline/1
        (workshop) lib/plug/debugger.ex:93: Workshop.Endpoint."call (overridable 3)"/2
        (workshop) lib/phoenix/endpoint/render_errors.ex:34: Workshop.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Steps to reproduce:

  1. Sign up for a mailgun account
  2. Do not active mailgun account (do not click the email verification link)
  3. Visit /register/ endpoint and create an account. Server throws a 500.
@trenpixster
Copy link
Owner

Thanks @StephenGrider! I'll make sure to have that addressed too 😄

@kevin-DL
Copy link

@StephenGrider Did you manage to get rid of the error?

Cheers.

@trenpixster
Copy link
Owner

@kevin-DL it seems what was missing was activating the mailgun account. Did you verify your e-mail address?

@kevin-DL
Copy link

@trenpixster : yes i have, in my case i have looked into it and it seems like it's not retrieving the configuration information. I will check my config.exs to see if i might have made a typo.

@kevin-DL
Copy link

kevin-DL commented May 23, 2016

That was it, some of my environment variables were not set properly.

Cheers.

It works on my local machine but not on heroku any ideas?

@kevin-DL
Copy link

It works properly on my local machine but not on heroku.
Any ideas?

@jaimeiniesta
Copy link

I'm having this exact issue. I'm using the the sandbox API that Mailgun creates when you sign up as my DNS haven't yet been verified.

@kevin-DL what environment variables were missing in your case?

@jaimeiniesta
Copy link

I've tried it on a real, verified, active domain associated to a verified Mailgun account, but it keeps on failing exactly like in the issue description.

@Devalo
Copy link

Devalo commented May 23, 2016

I'm having the exact same problem. I've added mailgun through heroku and copied the API-url from the active sandbox domain into addict during installation.
@kevin-DL also interested in those env variables you were missing :)

@kevin-DL
Copy link

In my case for my local env i was missing the env variable for the mailgun key was not set properly so returned nil when accessed

@kevin-DL
Copy link

It however does not work properly on heroku @Devalo for some reason. It was working at some point today but after an update it stopped working

@jaimeiniesta
Copy link

In my case it fails with Addict 0.2.4 and Mailgun client 0.1.2.

I've tried with the same Mailgun credentials in the example app that comes with Addict, and I get this error instead:

➔ mix phoenix.server
[info] Running ExampleApp.Endpoint with Cowboy using http on port 4000
[info] POST /register
[debug] Processing by Addict.AddictController.register/2
  Parameters: %{"email" => "jaimeiniesta@gmail.com", "name" => "Jaime", "password" => "[FILTERED]"}
  Pipelines: [:addict_routes]
[debug] INSERT INTO "users" ("inserted_at", "updated_at", "email", "encrypted_password", "name") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [{{2016, 5, 23}, {20, 8, 11, 0}}, {{2016, 5, 23}, {20, 8, 11, 0}}, "jaimeiniesta@gmail.com", "$pbkdf2-sha512$100000$l8htaZWlZXlhPWuocUhlwA$QgMIHTOWP5ebC8ojmP.ZZovmbPFI0xKHPz90hy4PEu1cHUuJ/BV52T7CoOEUKuA6ZGsfDcHa5AufU5H4/ZTqbA", "Jaime"] OK query=147.7ms queue=21.6ms
[debug] Unable to send e-mail to jaimeiniesta@gmail.com
:error
[debug] status: bad_fetch
[%{message: "Email: Unable to send e-mail (bad_fetch)"}]
[debug] reason:
[debug] no_scheme
[info] Sent 400 in 599ms

@trenpixster
Copy link
Owner

Really weird, everyone :| Can you try running mix deps.clean --all an try again?

@jaimeiniesta
Copy link

jaimeiniesta commented May 24, 2016

It works now! Thanks :) -- Tried it on the example app.

@kevin-DL
Copy link

Did not work for me. I will re-try my heroku install from scratch and see how it goes

@joshuaswilcox
Copy link

a mix deps.clean --all helped for me, not sure why though

@dianjin
Copy link

dianjin commented Jul 30, 2016

Yeah, same issue, and mix deps.clean --all worked! Thank you! 😄

@garviand
Copy link

  • Used mix deps.clean --all
  • Verified recipient emails were verified

Received error:

[debug] Unable to send e-mail to ga******@gmail.com
[debug] status: bad_fetch
[debug] reason:
[debug] no_scheme

@garviand
Copy link

In case this happens to anybody else, the issue was my mailgun_domain in config :addict

it was mailgun_domain: sandboxXXXX.mailgun.org

had to change it to mailgun_domain: https://api.mailgun.net/v3/sandboxXXXX.mailgun.org

@TB-Development
Copy link

In case this happens to anybody else, the issue was my mailgun_domain in config :addict

it was mailgun_domain: sandboxXXXX.mailgun.org

had to change it to mailgun_domain: https://api.mailgun.net/v3/sandboxXXXX.mailgun.org

This sent me in the right direction.

The updated link was in the API section of my Sending domains in any of the pre-built programs.

In my case, they added a /messages to the end fo the domain...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants