Skip to content Skip to sidebar Skip to footer

Django Sending Emails With Links

I have a sending code: def send_email(site_id, email): subject = 'Sub' from_email, to = EMAIL_FROM, email text_content = 'Text' html_content = render_to_string(

Solution 1:

I suspect that you are missing the absolute url in the link within your email template. When you send out an email, django fills in the url with a relative url "/results/30/" and perhaps your gmail mail client is filling in url with it's own domain and language prefix path.

You might try something like this:

<ahref="https://yoursite.com{% url 'mail_view' pk %}">Click</a>

Or to avoid hard-coding your domain in your template, you can use one of the techniques suggested below using the django sites framework or similar:

How can I get the domain name of my site within a Django template?

Post a Comment for "Django Sending Emails With Links"