chrismccord / mailgun

Elixir Mailgun Client
MIT License
194 stars 95 forks source link

Error in send_without_attachments/2 #22

Closed plamb closed 9 years ago

plamb commented 9 years ago

Simple mailer, shown below gets the following error when called. Works fine is test mode but trying to send an actual email fails. This is with Elixir 1.1.0 and Erlang 18.1.

** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir) lib/io.ex:333: 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
defmodule BrochureSite.Mailer do
  use Mailgun.Client, domain: Application.get_env(:my_app, :mailgun_domain),
                      key: Application.get_env(:my_app, :mailgun_key)

  @from "support@oil-law.com"
  @to_sales "paul@oil-law.com"

  def send_contact_me_email do
    send_email to: @to_sales,
               from: @from,
               subject: "Sales Lead",
               text: "There's a customer that wants to know more."
  end

end

I'm on heroku so config looks like:

config :brochure_site, mailgun_domain: System.get_env("MAILGUN_DOMAIN"),
        mailgun_key: System.get_env("MAILGUN_API_KEY")
plamb commented 9 years ago

:my_app in mailer should have been :brochure_site

Should have noticed that sooner.