Search code examples
javascriptnode.jssmtpsendmailsendgrid

Unable to display background image in email


I have a .tpl template to which I feed data and is sent through email to consumer, but in email I'm not getting background image, though I have debugged the request and got html going in sendEmail function, saved that in an html file and that is showing the background image but not in email. I am using SMPT of send grid for sending mails. here is css where I'm setting background image:

body {
        background-image: url('https://gallery.mailchimp.com/7d4c51bf7e89c06d7cbf03ed5/images/37260602-46f7-4061-bfad-43d962150495.png');
        background-repeat: no-repeat;
        background-size: cover;
        background-position: bottom center;
    }

does it has to do something sendgrid's SMTP Server? or I am doing something wrong?


Solution

  • Email clients are kinda tricky when it comes to styling and displaying things. More "ancient" methods have to be used You could try as a fallback along with your inline css, the following:

    background="URL" width="yourWidth" height="yourHeight" valign="top/bottom"