django-allauth - show user email address in confirmation email - django-allauth

I am sending out user sign-up/confirmation emails (django_allauth), and customising the templates for this function. Everything is working, emails are sent out, correct templates are being used, users can click links and confirm addresses, etc.
However, I would like to be able to display the email address in the confirmation email, ie something like:
The {{ user_name }} wants to confirm the email address {{ email_address }}…
It seems to me to be obvious that django_allauth "knows" the email address, since it is handling the sending/confirmation, but there doesn't seem to be any documentation as to how to access that attribute.

I was stuck with this issue for a LONG TIME, and there didn't seem to be any sources on the internet that could help me! But, it's actually really simple.
{{ user.email }}
will get you the user email. The default implementation for getting the username is
{% user_display user %}
, but I'm guessing you can also use {{ user.username }}
https://django-allauth.readthedocs.io/en/latest/templates.html#account-tags explains some of it. Good luck!

Related

Mandrill UNSUB merge tag not adding to blacklist

I put a merge tag in my email:
<a href="*|UNSUB:http://x.com/unsub.html|*">Click here to unsubscribe.</ a>
It is correctly turned into a link that takes me to the landing page, but the email recipient is not added to the blacklist.
I also see the List-Unsubscribe header in the email even though I don't explicit add that - expected.
The link is like (truncated):
http://mandrillapp.com/track/click/30738968/mandrillapp.com?p=eyJzIjoiRk96QWtzUE03NE5ROXFuWFpCX3RpUkJuNndz
The problem was patience. It took several hours to register on the black list.

How to get the email message body with ActionMailer

I am sending an standard email with Rails like this
#mail = mail(to: registration.user.email, subject: "Registration Confirmation: #{#site.name}")
Now i need to get the message body (or html in this case) from the email. I tried the following but it does not work since it returns not the rendered email but rather the template (including ERB and Haml).
#mail.body
#mail.body.raw_source
#mail.body.encoded
It seems surprisingly difficult to do this. I need the result that a persons sees when receiving the email.
Update
The ERB and Haml i saw was an HTML comment, that's why in the logs it looked like it logged ERB instead of a rendered tempalte. So #mail.body.encoded works fine.
I tried the accepted answer but it is showing the HEADER along with HTML. To get the HTML tags only I've used below code:
#mail.html_part.body.decoded
How about #mail.body.encoded (which should give you the result for which you seek)?

Rails confirmation email aol parsing error with email name

When I get a confirmation email sent via my rails app, I use this code
<a href='mailto:John%20Doe<Johndoe#random.com>?subject=Billing%20Submission'>LINK</a>
The email that shows up in all different emails is good except for aol.
In aol, it shows up as:
?subject=Billing%20Submission'>LINK
Is there any way around this without compromising the name being added?
Replace
<a href='mailto:John%20Doe<Johndoe#random.com>?subject=Billing%20Submission'>LINK</a>
With
<a href='mailto:John%20Doe%3CJohndoe#random.com%3E?subject=Billing%20Submission'>LINK</a>
> after Johndoe#random.com was actually ending the starting tag of a (anchor).
Use URL encoding equivalent for < (%3C) and > (%3E) sign.

How to put a button to action in an email template in RoR

My application sends notification emails to users, I would like to put a button in the email that links to a certain action in a controller?
When I put regular html code (like <input type="button" .... />, I get it in the received email as string, that is, I find the html code in the email) How can I skip this trap?
It's not a perfect idea to send messages as html. By default I turn off html in my email account.
Look this screencast for a beginning: http://railscasts.com/episodes/206-action-mailer-in-rails-3. You just need to specify different view formats: html or text for plain text. But in any case it will rely on reciever email settings which format will be choosen.

how to reset page text boxes data after page post back?

my question seems simple and stupid
but first read this,
suppose you have a login form which take username and password and post back to controller
if login successful then return Homepage(return View("HomePage")) View (not Redirect) then suppose i am Logged off
and return Login (return View("Login")) View (again not Redirect) and now if i press Back button and Refresh the page then it will automatically get logged IN by using those username and password which i entered before.
So can i make those password Null from Browser's Memory or where ever it is i don't know.
"i know that not redirecting (RedirectToAction("ViewName")) is causing the problem" But Why or May be i don't know any important concept
Some browsers, especially Firefox try to be helpful and 'remember' values you have input into text fields and checkboxes. in order to switch this off in a particular input add the following attribute
autocomplete="off"
Alternatively, using jQuery you can switch it off for a whole form:
$("form").attr("autocomplete", "off");
ModelState.Remove("key");
or
ModelState.Clear()

Resources