martins
Can't get Swoosh to use the template I'm specifying.
Hi,
I´m trying to send email using Phoenix.Swosh, but I get this error message that I don´t really understand.
This is how I send the mail:
MyCompany.UserEmail.mail_requesting_signature(%{
contract: contract,
current_user: sender
})
|> MyCompany.Mailer.deliver()
defmodule MyCompany.UserEmail do
use Phoenix.Swoosh,
template_root: "lib/MyCompany_web/templates/emails/",
template_path: "requesting_signature"
def mail_requesting_signature(%{
contract: contract,
current_user: current_user
}) do
sender_email = extract_string(current_user.email)
recipient_email = contract.client.email
recipient_name = "John Doe"
new()
|> to({recipient_email, recipient_name})
|> from({"MyCompany", "no-reply@MyCompany.no"})
|> subject("#{sender_email} has invited you to sign a contract")
|> render_body(
"requesting_signature.html.heex",
%{
username: user.email,
title: contract.title,
content: contract.content,
}
)
end
end
** (Phoenix.Template.UndefinedError) Could not render "mail_template.html.heex" for MyCompany.UserEmail, please define a matching clause for render/2 or define a template at "lib/MyCompany_web/templates/emails/mail_template/*". The following templates were compiled:
* mail_template.html
Assigns:
%{title: "Pacocha Group", username: "user.email", email: %Swoosh.Email{subject: "merlin_gibson@rempel.org has invited you to sign a contract", from: {"MyCompany", "no-reply@MyCompany.no"}, to: [{"deion2076@balistreri.biz", "John Doe"}], cc: [], bcc: [], text_body: nil, html_body: nil, attachments: [], reply_to: nil, headers: %{}, private: %{phoenix_view: MyCompany.UserEmail, phoenix_template: "mail_template.html.heex", phoenix_layout: false}, assigns: %{title: "Pacocha Group", layout: false, username: "user.email", content: "Vero repellendus velit in nihil enim voluptatem rerum est et. Voluptate vel aspernatur et accusantium mollitia ea reprehenderit expedita aut. Et debitis veritatis dolore tenetur cumque et ut. Expedita itaque maxime dolorem autem. Perspiciatis eum dolores rerum delectus dolores commodi sunt.", sign_url: "http://localhost:4000/contracts/f46b280d-e05e-418b-805a-079f473db7ae/sign"}, provider_options: %{}}, content: "Vero repellendus velit in nihil enim voluptatem rerum est et. Voluptate vel aspernatur et accusantium mollitia ea reprehenderit expedita aut. Et debitis veritatis dolore tenetur cumque et ut. Expedita itaque maxime dolorem autem. Perspiciatis eum dolores rerum delectus dolores commodi sunt."}
Assigned keys: [:title, :username, :email, :content,]
The template:
lib/quantik_web/templates/emails/requesting_signature/requesting_signature.html.heex
<div>
<h1>Document to be signed</h1>
<h1>Welcome to MyCompany, <%= @username %>!</h1>
<pre> Please read the document below: </pre>
<h2><%= @title %></h2>
<pre> <%= @content %> </pre>
</div>
Most Liked
Popular in Questions
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Other popular topics
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New








