1

I have made an email template that gets sent once the user completes the registration. The template contains some icons from font-awesome, images, and some imported Google fonts.

These items are getting rendered perfectly when I am viewing the HTML file on the browser but when this is sent as an email nothing is getting rendered other than the texts only.

I tried moving the CSS styling inline but that doesn't work either. I am unable to understand what the problem is. Below is the code.


{% load static %}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <!--<link rel="stylesheet" href="{% static 'regd_success_email.css' %}">-->
<style>
    @import url('https://fonts.googleapis.com/css2?family=Carattere&display=swap');

body
{
    margin: 0;
    padding: 0;
}


table
{
    border-spacing: 0;
}

td
{
    padding: 0;
}


.wrapper
{
    width: 100%;
    table-layout: fixed;
    background-color: #cccccc;
    padding-bottom: 60px;
}

.welcome
{
    font-family: 'Carattere', cursive;
    
}

.main
{
    background-color: #ffffff;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    border-spacing: 0;
    font-family: sans-serif;
    color: #4a4a4a;
}

.email-body
{
    font-family: 'Carattere', cursive;
    font-weight: bold;
    font-size: 25px;
    padding: 5px 0 15px;
}

.button
{
    background-color: #289dcf;
    color: #ffffff;
    text-decoration: none;
    padding: 12px 12px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
}

.subs-and-pays
{
    font-size: 15px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    padding: 5px 0 5px;

}





@media screen and (max-width:600px) {
    
}


@media screen and (max-width: 400px) {
    
}
</style>



</head>
<body>
    


    <center class="wrapper">
        <table class="main" width="100%">

            <tr>
                <td height="8" style="background-color: #289dcf;"></td>
            </tr>

            <tr>
                <td style="background-color: #001035;">
                    <a href="http://127.0.0.1:8000/">
                        <img src="{% static '../static/images/logo1.png' %}" alt="" width="600px" style="max-width: 100%;">
                    </a>
                </td>
            </tr>

            <tr>
                <td style="padding: 5px 0 50px;">
                    <table width="100%">

                        <tr>
                            <td style="text-align: center; padding: 15px">
                                <p style="font-size: 50px;" class="welcome"><strong style="color: #289dcf;">Welcome to Solve Litigation</strong></p>

                                <p class="email-body">Hello, {{name}}, you have been succesfuly registered with Solve Litigation.</p>

                                
                                <a href="http://127.0.0.1:8000/" class="button">Go to Website <i class="fas fa-arrow-circle-right"></i></a>
                                

                            </td>
                        </tr>

                    </table>
                </td>
            </tr>

            
            <tr>
                <td height="2" style="background-color: #a6d8ee;"></td>
            </tr>

            <tr>
                <td style="padding: 5px 0 20px;">
                    <table width="100%">

                        <tr>
                            <td style="text-align: center; padding: 15px">
                                <p style="font-size: 20px;"><strong style="color: #289dcf;">Subscription and Payments</strong></p>

                                <p class="subs-and-pays"> For Subscription details and Payment methods click on the <strong> User Profile </strong> button after you login and then click on <strong>Payments</strong>. </p>
                            </td>
                        </tr>

                    </table>
                </td>
            </tr>

            <tr>
                <td height="2" style="background-color: #a6d8ee;"></td>
            </tr>

            <tr>
                <td style="padding: 5px 0 20px;">
                    <table width="100%">

                        <tr>
                            <td style="text-align: center; padding: 15px">
                                <p style="font-size: 20px;"><strong style="color: #289dcf;">Contact Us <i class="fas fa-envelope"></i> </strong></p>

                                <p class="subs-and-pays"> To contact us regarding more details, updation of the information provided during registration or any other queries, click on the <strong> User Profile </strong> button after you login and then click on <strong>Contact</strong>. </p>
                            </td>
                        </tr>

                    </table>
                </td>
            </tr>

            <tr>
                <td height="8" style="background-color: #289dcf;"></td>
            </tr>


        </table>
    </center>

   
    
</body>
 <script src="https://kit.fontawesome.com/2b3aa8f23b.js" crossorigin="anonymous"></script>
</html>

This is a Django project so the image URLs I wrote are the convention of Django template language.

Henry
  • 3,472
  • 2
  • 12
  • 36

2 Answers2

1

You need to host your images externally (and have them be publicly accessible) for them to be visible in an email or send them as an attachment.

Add your images to an image hosting service and replace your paths with absolute links to them.

You can also send your images as attachments but this is a less preferred option as it can increase the size of your email, which in turn can cause it to be blocked by email filters.

This answer has details on adding images as attachments in Django.

nima
  • 7,796
  • 12
  • 36
  • 53
dave
  • 2,750
  • 1
  • 14
  • 22
1

You can't use webfonts reliably in html emails. Some clients might respect and render them, but the majority don't.

You can use font awesome to png website to convert the icons into images, and Add it to an image hosting service to show them in email template

M_H
  • 21
  • 1
  • 6