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
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
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
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Other popular topics
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hello, how can I check the Phoenix version ?
Thanks !
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
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









