{"action":"created","issue":{"url":"https://api.github.com/repos/chrismccord/mailgun/issues/24","labels_url":"https://api.github.com/repos/chrismccord/mailgun/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/chrismccord/mailgun/issues/24/comments","events_url":"https://api.github.com/repos/chrismccord/mailgun/issues/24/events","html_url":"https://github.com/chrismccord/mailgun/issues/24","id":111232961,"number":24,"title":"Config errors when a dependency depends on Mailgun","user":{"login":"Zensavona","id":425801,"avatar_url":"https://avatars.githubusercontent.com/u/425801?v=3","gravatar_id":"","url":"https://api.github.com/users/Zensavona","html_url":"https://github.com/Zensavona","followers_url":"https://api.github.com/users/Zensavona/followers","following_url":"https://api.github.com/users/Zensavona/following{/other_user}","gists_url":"https://api.github.com/users/Zensavona/gists{/gist_id}","starred_url":"https://api.github.com/users/Zensavona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zensavona/subscriptions","organizations_url":"https://api.github.com/users/Zensavona/orgs","repos_url":"https://api.github.com/users/Zensavona/repos","events_url":"https://api.github.com/users/Zensavona/events{/privacy}","received_events_url":"https://api.github.com/users/Zensavona/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-13T17:49:01Z","updated_at":"2015-12-10T23:59:12Z","closed_at":null,"body":"Hi, I'm having some issues with the config being set when using mailgun from within a library I'm building, it's very possible I'm at fault here but I'm new to Elixir so maybe you can point me in the right direction...\r\n\r\nI'm getting this error:\r\n\r\n```\r\n[error] #PID<0.454.0> running HrTest.Endpoint terminated\r\nServer: localhost:4000 (http)\r\nRequest: POST /user/new\r\n** (exit) an exception was raised:\r\n    ** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1\r\n        (elixir) lib/io.ex:330: IO.chardata_to_string(nil)\r\n        (elixir) lib/path.ex:467: Path.join/2\r\n        (elixir) lib/path.ex:449: Path.join/1\r\n        (mailgun) lib/client.ex:44: Mailgun.Client.send_without_attachments/2\r\n        (hr) lib/hr/form_controller.ex:258: Hr.FormController.create_signup/2\r\n        (hr) lib/hr/form_controller.ex:257: Hr.FormController.action/2\r\n        (hr) lib/hr/form_controller.ex:257: Hr.FormController.phoenix_controller_pipeline/2\r\n        (hr_test) lib/phoenix/router.ex:255: HrTest.Router.dispatch/2\r\n        (hr_test) web/router.ex:1: HrTest.Router.do_call/2\r\n        (hr_test) lib/hr_test/endpoint.ex:1: HrTest.Endpoint.phoenix_pipeline/1\r\n        (hr_test) lib/plug/debugger.ex:90: HrTest.Endpoint.\"call (overridable 3)\"/2\r\n        (hr_test) lib/phoenix/endpoint/render_errors.ex:34: HrTest.Endpoint.call/2\r\n        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4\r\n        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4\r\n```\r\n\r\nSo, I've got a dependency to my main application which has a mailer like this:\r\n\r\n```\r\ndefmodule Hr.MailHelper do\r\n  use Mailgun.Client, domain: Application.get_env(:hr, :mailgun_domain),\r\n                     key: Application.get_env(:hr, :mailgun_key),\r\n                     mode: Application.get_env(:hr, :mailgun_mode),\r\n                     test_file_path: Application.get_env(:hr, :mailgun_test_file_path)\r\n  @dir \"web/templates/hr_email/\"\r\n\r\n  def send_confirmation_email(user, link) do\r\n    send_email to: user.unconfirmed_email,\r\n               from: Application.get_env(:hr, :register_from_email),\r\n               subject: Application.get_env(:hr, :confirmation_email_subject),\r\n               html: EEx.eval_file(@dir <> \"signup_confirmation.eex\", [user: user, link: link])\r\n  end\r\n\r\n  def send_reset_email(user, link) do\r\n    send_email to: user.email,\r\n               from: Application.get_env(:hr, :password_recovery_from_email),\r\n               subject: Application.get_env(:hr, :recovery_email_subject),\r\n               html: EEx.eval_file(@dir <> \"password_reset.eex\", [user: user, link: link])\r\n  end\r\nend\r\n```\r\n\r\nand the main application (which depends on the library which includes that mailer) has these configs set as:\r\n\r\n```\r\nconfig :hr, register_from_email: \"Registration <welcome@example.com>\",\r\n            password_recovery_from_email: \"Password Recovery <no-reply@example.com>\",\r\n            confirmation_email_subject: \"Confirm Your Account\",\r\n            recovery_email_subject: \"Reset Your Password\",\r\n            mailgun_domain: \"https://api.mailgun.net/v3/mydomain.com\",\r\n            mailgun_key: \"key-##############\",\r\n            mailgun_mode: :test,\r\n            mailgun_test_file_path: \"/tmp/mail.json\"\r\n```\r\n\r\nI've done a bit of digging and if I pop a `IO.inspect conf` and `IO.inspect email` in at Line 44 of `mailgun/lib/client.ex`, it is getting the email, but not the conf, so my application config is working... The other interesting thing is that if I make a change to the mailer in the library, it recompiles(?) and then everything works. If I include the library into a fresh mix.phoenix project, it breaks again (in the new application, but not the old one). I am guessing this is something to do with compilation of macros?\r\n\r\nFWIW I've tried using `{:hr, path: \"../path\"}` and `{:hr, git: \"some-git-url\"}` in the hope that if it's fetched remotely it will be recompiled and achieve the same effect as making a change to the source, but they behave exactly the same.\r\n\r\nDo you have any idea what could be causing this / Is there a way around it?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/chrismccord/mailgun/issues/comments/163790615","html_url":"https://github.com/chrismccord/mailgun/issues/24#issuecomment-163790615","issue_url":"https://api.github.com/repos/chrismccord/mailgun/issues/24","id":163790615,"user":{"login":"backspace","id":43280,"avatar_url":"https://avatars.githubusercontent.com/u/43280?v=3","gravatar_id":"","url":"https://api.github.com/users/backspace","html_url":"https://github.com/backspace","followers_url":"https://api.github.com/users/backspace/followers","following_url":"https://api.github.com/users/backspace/following{/other_user}","gists_url":"https://api.github.com/users/backspace/gists{/gist_id}","starred_url":"https://api.github.com/users/backspace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backspace/subscriptions","organizations_url":"https://api.github.com/users/backspace/orgs","repos_url":"https://api.github.com/users/backspace/repos","events_url":"https://api.github.com/users/backspace/events{/privacy}","received_events_url":"https://api.github.com/users/backspace/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T23:59:12Z","updated_at":"2015-12-10T23:59:12Z","body":"Hey, @duksis, I was able to get it working on Heroku by creating `elixir_buildpack.config` with this line:\r\n\r\n    config_vars_to_export=(DATABASE_URL MAILGUN_KEY)"}}