0
我試圖按照tut在我的鳳凰應用程序中創建一個郵件程序。我有很遠,但現在我想從IEX控制檯我得到以下錯誤發送測試電子郵件:'通過Heroku在Phoenix應用程序中使用Mailgun參數無效錯誤
iex(2)> Radios.Mailer.my_first_email("[email protected]")
{:error, 400,
"{\n \"message\": \"'to' parameter is not a valid address. please check documentation\"\n}"}
mailer.ex
defmodule Radios.Mailer do
use Mailgun.Client,
domain: Application.get_env(:radios, :mailgun_domain),
key: Application.get_env(:radios, :mailgun_key)
def my_first_email(email_address) do
send_email to: "email_address", #<= this appears to be the issue
from: "[email protected]",
subject: "My first email",
text: "This is an email send with Phoenix and Mailgun"
end
end
config.exs
config :radios,
ecto_repos: [Radios.Repo],
mailgun_domain: "https://api.mailgun.net/v3/XXXXXXXXX.mailgun.org",
mailgun_key: "pubkey-XXXXXXXX"
我一直在瞎搞改變雙引號單,並send_email(to: :email_address)
剛纔還廣告在那裏還有我自己的實際地址。
所有沒有喜悅。
我錯過了什麼?
更新 物是人非config.exs到下面:
config :radios, Radios.Mailer,
mailgun_domain: "https://api.mailgun.net/v3/XXXXXXXX.mailgun.org",
mailgun_key: "pubkey-XXXXXX"
但現在得到:
iex(1)> Radios.Mailer.my_first_email("[email protected]")
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
(elixir) lib/io.ex:445: IO.chardata_to_string(nil)
(elixir) lib/path.ex:468: Path.join/2
(elixir) lib/path.ex:450: Path.join/1
lib/client.ex:44: Mailgun.Client.send_without_attachments/2
錯字? ''email_address''應該是'email_address',因爲你想使用變量的值,而不是字符串'「email_address」'。 – Dogbert
'send_email to:email_address,'發出相同的錯誤。 –
完全相同的錯誤?你確定? – Dogbert