AhmAch
AhmAch

Reputation: 105

how to send an image to email in html/EJS

I am sending an email verification trying to send the logo of the company in the html file I created to be sent. Everything works fine except the logo which is not really sended correctly.

Here is the result and the logo should be in the blue div : enter image description here

this is function of sending the mail using loopback(node.js framework) :

 user.afterRemote('create', function (context, user, next) {

    var nom = user.nom

    var options = {
      type: 'email',
      to: user.email,
      from: senderAddress,
      subject: 'Thank you for registering',
      template: path.resolve(__dirname, '../../lib/mail.ejs'),
      redirect: 'http://localhost:3001/home',
      host: 'localhost',
      text: '\n\t{href}',
      nom: nom,
      body: 'Veuillez vérifier votre email, en cliquant sur ce lien :',
      port: '3000',
      user: user
    };

    user.verify(options, function (err, response) {
      context.res.render('response', {
        title: 'Signed up successfully',
        content: 'Please check your email and click on the verification link before logging in.',
        redirectTo: '/',
        redirectToLinkText: 'Log in'
      });
    });
  });

and this is my html where to insert the image :

<table border="0" cellpadding="30" cellspacing="0" width="100%">
  <tr>
    <td align="center" valign="top" class="textContent">
      <img src="../public/images/logo-casting.png" width="210" class="flexibleImage" alt="Logo" title="Logo" style="display:block" />
   </td>
  </tr>
</table>

Upvotes: 0

Views: 969

Answers (1)

Swetha Lakshmi
Swetha Lakshmi

Reputation: 1969

You can't directly take image from your own project directory path. because you are sending http. So upload your image to a website and paste the url.

Upvotes: 1

Related Questions