postal
postal copied to clipboard
Chokes on "<" and ">" in headers
I understand that a Postal from, sender, to, cc, bcc field should look like this: Foo Bar [email protected]
.
We use the MailAddress
class for all sorts of stuff, and so I already have the email database in that format, and when I call mymailaddress.ToString()
you get Foo Bar <[email protected]>
. Which is all OK.
But those angle brackets cause Postal to choke, because when it puts those strings into a new MailAddress
, you get an exception.
Is there some easy way to avoid this? Ideally, somewhere in the parsing there should be something like somestring.Replace("<","").Replace(">","")
. Does Postal check for this? If not, it probably should because that is the standard header format.
I can send a PR if you give me a clue where in the code to make this change.
I have no problems using angle brackets in headers. However, the Razor view itself chokes on them, unless you take precautions. Perhaps that's what your issue is?
Anyways, this is all I do:
@Html.Raw("<[email protected]>")
If your var already has the angle brackets embedded in the string, just do:
@Html.Raw(myEmailVar)
any update on this? Html.Raw isnt working for me
I'm still using this successfully in production. If Html.Raw isn't working for you there's some other issue at play. Can you provide any more detail as to how it's not working for you, including any exceptions and stacktraces?
I was having an issue with < > choking in the template too. When I went to use @Html.Raw I found that the call wouldn't work when using Postal outside of ASP.Net. I fixed this by using a RawString call instead of Html.Raw:
From: @(new RazorEngine.Text.RawString(Model.From))
The only thing that work form me is to remove the < and > from the Model.From