Comments (13)
Excuse me, in my post i wanted write
lib/shuttertop_web/templates/layout/email.text.eex
Ok if it works to you, i'll check more my code.
Thanks anyway!
from phoenix_swoosh.
Hi, could you try phoenix_swoosh
1.0.0-rc.0?
from phoenix_swoosh.
There should be no breaking change and should work with phoenix 1.6
from phoenix_swoosh.
I upgraded also phoenix_swoosh with:
{:phoenix_swoosh, git: "https://github.com/swoosh/phoenix_swoosh"},
but it the same.
The problem is that the render_body returns nothing and there are no logs.
from phoenix_swoosh.
Hi @romaluca I'm going to need more info to debug that. Testing with a toy project shows that it works properly with atoms.
Could you setup a minimal reproducible example?
What I got:
lib/test_swoosh/something.ex
defmodule TestSwoosh.Something do
use Phoenix.Swoosh, view: TestSwoosh.MyView
def hi do
new()
|> subject("what")
|> to("[email protected]")
|> from("[email protected]")
|> render_body(:hi, name: "world")
end
end
lib/test_swoosh/my_view.ex
defmodule TestSwoosh.MyView do
use Phoenix.View, root: "lib/test_swoosh/templates"
end
lib/test_swoosh/templates/my/hi.html.eex
<h1>Hello, <%= @name %></h1>
lib/test_swoosh/templates/my/hi.text.eex
Hello, <%= @name %>
iex(1)> TestSwoosh.Something.hi
%Swoosh.Email{
assigns: %{layout: false, name: "world"},
attachments: [],
bcc: [],
cc: [],
from: {"", "[email protected]"},
headers: %{},
html_body: "<h1>Hello, world</h1>\n",
private: %{
phoenix_layout: false,
phoenix_template: "hi.text",
phoenix_view: TestSwoosh.MyView
},
provider_options: %{},
reply_to: nil,
subject: "what",
text_body: "Hello, world\r\n",
to: [{"", "[email protected]"}]
}
from phoenix_swoosh.
render_body
should always return the rendered email struct. There is not a case where it would return nothing.
from phoenix_swoosh.
i found the cause is the layout. I have this:
use Phoenix.Swoosh, view: ShuttertopWeb.UserMailerView, layout: {ShuttertopWeb.LayoutView, :email}
and these files for the common layout:
lib/shuttertop_web/templates/layout/email.html.eex
lib/shuttertop_web/templates/layout/email.txt.eex
If i remove this from the code it works:
layout: {ShuttertopWeb.LayoutView, :email}
I tried also to change the content of the layout files with only:
<%= render @view_module, @view_template, assigns %>
or
<%= @inner_content %>
But it doesn't work.
from phoenix_swoosh.
I tried the send with iex and there is an error:
[error] %ArgumentError{message: "errors were found at the given arguments:\n\n * 1st argument: not an iodata term\n"}
from phoenix_swoosh.
lib/shuttertop_web/templates/layout/email.txt.eex
Has this always been txt
? Could you try text
?
from phoenix_swoosh.
I added layout and still works. I did get an error, but a different one, if I named it email.txt.eex
, though.
lib/test_swoosh/something.ex
defmodule TestSwoosh.Something do
use Phoenix.Swoosh, view: TestSwoosh.MyView, layout: {TestSwoosh.LayoutView, :email}
def hi do
new()
|> subject("what")
|> to("[email protected]")
|> from("[email protected]")
|> render_body(:hi, name: "world")
end
end
lib/test_swoosh/layout_view.ex
defmodule TestSwoosh.LayoutView do
use Phoenix.View, root: "lib/test_swoosh/templates"
end
lib/test_swoosh/templates/layout/email.html.eex
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<%= @inner_content %>
</body>
</html>
lib/test_swoosh/templates/layout/email.text.eex
TEST <%= @inner_content %>
iex(8)> TestSwoosh.Something.hi
%Swoosh.Email{
assigns: %{layout: {TestSwoosh.LayoutView, "email.text"}, name: "world"},
attachments: [],
bcc: [],
cc: [],
from: {"", "[email protected]"},
headers: %{},
html_body: "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Document</title>\n </head>\n <body>\n<h1>Hello, world</h1>\n\n </body>\n</html>\n",
private: %{
phoenix_layout: {TestSwoosh.LayoutView, :email},
phoenix_template: "hi.text",
phoenix_view: TestSwoosh.MyView
},
provider_options: %{},
reply_to: nil,
subject: "what",
text_body: "TEST Hello, world\r\n\n",
to: [{"", "[email protected]"}]
}
from phoenix_swoosh.
Did you manage to figure out what the issue is?
from phoenix_swoosh.
Yes, i used the same LayoutView for web pages and email
Before phoenix 1.6 it worked.
I created another LayoutView for email and now it works again.
Thanks
from phoenix_swoosh.
Interesting. Thanks for the reply.
from phoenix_swoosh.
Related Issues (17)
- Error when following User_Email example HOT 1
- Release a version based on phoenix 1.3.0-rc HOT 2
- respect the bang syntax HOT 1
- Not yet published? HOT 2
- Implement .render_subject/2 and .render_subject/3 HOT 3
- Mismatch of File doc and Hexdoc HOT 1
- A heads up: we have extract phoenix_view into a separate project HOT 2
- would it be possible to do another release ? HOT 4
- Upgrading to Swoosh 0.13 HOT 2
- How is the struct %Email{} available? HOT 3
- Phoenix 1.7 and phasing out Phoenix.View HOT 24
- ArgumentError: 1st argument: not an iodata term HOT 6
- phoenix_html 4.0 compatibility HOT 2
- render_body exception when using email as an assign. HOT 1
- Incorrect Swoosh.Email struct keys set HOT 5
- Why does it need to be in application HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phoenix_swoosh.