How to Include image in email using sails email hook - sails.js

Sails version: 0.12.14
sails-hook-email: 0.12.1
I am trying to send image in the email so that I can show in the email, and below is the code,
Note: I don't want to send it as an attachment, but want to show in the html.ejs page itself (i.e. in the email itself).
views/emailTemplates/forgotPassword/html.ejs
<p>Dear <%=recipientName%>,</p>
<br/>
<img src="/images/img1.png" width="300">
But it is not visible in the mail.
So how to include the images from assets/images folder to the above html.ejs file and make them visible in the mail that we send.
Please help me.

If your app is available on the internet, you can do that just by giving the making the src attribute absolute instead of relative. Something like this:
<img src="http://mywebsite.com/images/img1.png" width="300">
If your app is just on localhost or not online, then this won't work. The only solution then is to "embed" them image, which some email clients will display as attachments.
Note that some clients may show a "blocked remote content / click to allow remote content" message before they show your image properly.

Related

OCTOBERCMS Obfuscate an email address with html_email

i wanna obfuscate an email address to prevent spam-bots from sniffing it on my contact page.
I tried to use html_email function in href but the email address remained unchanged.
E-mail: My email
Anyone have any idea why the html_email function doesn't work.
Maybe another solution to obfuscate a email address in october?
It is working. If you look at the source file it is obfuscated. I believe bots sniff the source file. You are looking at the rendered html which displays the email correctly. Also if you use google chrome you can do ctrl-u to look at the source file. Firefox I just right click and click on view source and etc with more browsers.

How can I make the images in the email template to show in every client?

The images embedded in the body of a Visualforce email template don't show in all the clients.
I am not sure where to start. I've tried to set the tag to <apex:image/> and <img />.
Tried to use URLFOR($Resource.Static) in the value attribute.
Tried to copy/paste the image server link.
I expect that the images in the body show in every client.
So far all the images are replaced by the alt attributes or just a blue border.
alt's might be there because client is not trusting SF and you need to explicitly allow downloading images, asking your recipients to add you to safe senders list etc.
But that's not all. Static resources are served from generic domain. There's nothing really tying them to given org (even if it has MyDomain enabled). They rely on your cookies for redirect to right org's resources and don't work well in email templates or VF pages set to renderAs="pdf".
You should use old-school Documents (if you're in Lightning UI - flip back to Classic), upload your stuff there, make sure "externally available image" checkbox is ticked...
Or in Files I think you can set deliveries, build the direct download URL too that should work OK (look for something with "shepherd" in URL, I know it sounds stupid)

How to display images within html email content in gmail?

In yahoomail and html email, the images are loading but not in gmail. I observed that in gmail, the image urls are altered.
For example,
Image URL in yahoo/Hotmail : http://qaecmwcs.qacorp.moneygram.com/sites/Satellite?blobcol=urldata&blobkey=id&blobnocache=true&blobtable=MungoBlobs&blobwhere=1515690635784&ssbinary=true
Url for the same image in Gmail : https://ci5.googleusercontent.com/proxy/2B2Fyk0aboH-eiikaxVWdIC9DXbJzhZEuWKm5yPwUeXf3SdYRuoKBGT-HeCFRlNcg7VTzljtSsEhHkikFMGPac35C6Az2Fc2wsdig3xj0S3g1bEIABaMx9RKnTjYuqagP1hUGNl3GG4f2aHy26wHrINZkdn5Wv3y6zcvbWHUL8rabUcjHuCO05i8RM31x8iFJmUorccqIJM6P9f6-eLIaQ5GpZYCrKPJws72HfM2-AsXcg=s0-d-e1-ft#http://qaecmwcs.qacorp.moneygram.com/sites/Satellite?blobcol=urldata&blobkey=id&blobnocache=true&blobtable=MungoBlobs&blobwhere=1515690635784&ssbinary=true
When I manually remove the additional url part in the image src,from DevTools then I am able to see the image. Can any one please let me know how I can handle this in gmail?
If you want an image to work in email, it has to be viewable by your audience. The image path should be straightforward and simple. What you have posted over and over in your questions are images that are not accessible to the general public, so they will never work for an email.
Image Path
This is how an image should be formatted:
<img src="staticpath" alt="imagename" class="imageclass" />
<img src="https://www.w3schools.com/images/w3schools_green.jpg" width="104" height="142" alt="W3Schools.com">
<img src="https://placehold.it/600x600" height="600" width="600" />
More information:
https://www.w3schools.com/html/html_images.asp
Image Descriptors
As a best practice, an image path should end in a descriptor that defines what the format of the image. Images that work well with emails include .jpg .png .gif.
More Information:
https://litmus.com/blog/png-gif-or-jpeg-which-ones-should-you-use-in-email
Email Templates
Your email templates should follow the basic practices of a well-formatted html page. Email development is not Web development because email clients do not support current html 5 or css 3 standards. So it can be very hit and miss to create a complex email.
The following email templates will give you a good idea how an email should be created, how images should look, how image classes work.
Email template Examples:
http://tedgoas.github.io/Cerberus/
https://foundation.zurb.com/emails/docs/v1.0.5/index.html
Please take the time to read through this answer, read through the attached examples.
Best Practices & Considerations when writing HTML Emails
Good luck with your images.
The firewall was blocking the images from displaying. When client opened the firewall then the images within the server are loaded.

Image not display in Newsletters

I am sending the newsletter to the target leads via day CQ mail service in CQ5, My newsletter template contains an image from DAM (via drap/drop). My Newsletter sent successfully to the audience but image not getting display. Below is the img src generate once i receive the newsletter.
<img title="logo" alt="logo" src="https://ci3.googleusercontent.com/proxy/dBvtBcRC6SpELT7-2A_TARSjSJ3t7HDuxtIKWk-QoU7yCISyVeR1JledcIr6oleEkY2SxBZgJwGsjeDn8VQA653Omj_MQHScJgbZ-kKwiC6YHNsfeE2dS8tErqhQKvQIG8Y5MGk3MJhHdyzAydO5JZNxUxvAjNlCVTXjOpyoC2J-K-062Ec8aaT-UpkinvASKg=s0-d-e1-ft#http://localhost:4502/content/campaigns/myApp/Newsletter/Monthly-Newsletter/_jcr_content/header.img.png/1427268772034.png" class="CToWUd">
Any Idea how to resolve it.
Thanks
Gmail does not directly link to the image , they use proxies. From the img src you have posted the image link is
http://localhost:4502/content/campaigns/myApp/Newsletter/Monthly-Newsletter....
Since google's server can't reach your local instance the image is not being displayed.
References :
https://filippo.io/how-the-new-gmail-image-proxy-works-and-what-does-this-mean-for-you/
https://support.google.com/a/answer/3299041?hl=en

Get Content-ID of attached image when composing a new email in iOS

I'm using the MFMailComposeViewController in iOS to create a new dynamic email but have run into an issue when trying to use inline images.
I first tried adding the image as a base64 encoded string, i.e.
<img src="data:image/png;base64, blahblahblah" />
But I can only view that on the iPad while Outlook/Entourage ignore it even though I can see it in the source!
So now I'm trying to add the image as an attachment and link to it via it's content ID, i.e.
<img src="cid:BF6E8B41-4D74-419E-B55E-8F18A07381AE" id="BF6E8B41-4D74-419E-B55E-8F18A07381AE" width="509" height="220">
But have no clue how to get the cid through code!
When I attach an image using AddAttachmentData, the image goes to the bottom and actually generates an <img /> tag with the cid!
Additionally, this ID seems to change with every new email. The one above was my first try, then I sent another one and the Content-ID changed to
<img src="cid:59EBFDED-2A31-4787-BF67-9D9ED0FF2B39" id="59EBFDED-2A31-4787-BF67-9D9ED0FF2B39" width="509" height="220">
The reason I have to do this is because this is a dynamically generated image and it needs to sit inside an email template.
EDIT
I'm beginning to think that this isn't possible. I've been researching for hours now and it looks like iOS won't let you attach an image and link to it via its CID. Thanks Apple -_-
I've hit the same limitation of MFMailComposeViewController. It exposes no way to get content id (cid) of an email attachment, so there is no way to compose an html email message that references the attachment via img src='cid:...'. Since most email clients ignore data urls (inline base 64 encoded images), the best option for composing an html email message with images from an iOS app is to host the images on the web and reference them as img src='http://...'. Most email clients will ask the user for permission to download the images, so this is not ideal, but it's apparently the only option in iOS using public APIs.