How to create a beautiful, functional Pricing Slider with Tailwind CSS and Alpine.js
A detailed guide on building a pricing slider using Tailwind CSS and Alpine.js, with support for non-linear scaling, multiple currencies and custom price logic
" data-copied="Copied!">
This works by attaching the image, then referencing the image in the email with an HTML image tag. Most email clients are smart enough to realize that the image is attached and will display it correctly.
Here’s an example of how to do this using cid
(Content-ID) referencing, in your email include this line:
<img src="cid:unique-image-id" alt="Embedded Image" />
When sending the email, attach the image and set its Content-ID to match the cid
used in the HTML tag. For example, in a MIME email, the attachment part might look like this:
--boundary-stringContent-Type: image/pngContent-Transfer-Encoding: base64Content-ID: <unique-image-id>
<base64-encoded-image-data>--boundary-string
At MailPace this simple, just include an attachment with a matching CID. Here’s an example using the MailPace API to send an email with an inline attachment:
curl "https://app.mailpace.com/api/v1/send" \ -X POST \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "MailPace-Server-Token: API_TOKEN_GOES_HERE" \ -d '{ "from": "example@domain.com", "to": "person@somewhere.com", "htmlbody": "<img src="cid:unique-image-id" alt="Embedded Image" />". "attachments": "[{ "name": "attachment.jpg", "cid": '<unique-image-id>', "content": "<base64-encoded-image-data>", "content_type": "image/jpeg" }]" }'
This method is useful because the email is fully self-contained, and images are only attached once but can be referenced multiple times within the email. However, inline images are often not the primary content of the email (so why make your email larger and slower for them?), and many email clients or recipients may block images by default.
Although the methods above can work on the web in general, the way almost all scalable image hosting is done is through a Content Delivery Network (CDN). By hosting your images externally and referencing them via URL, you can ensure that your images are cacheable, scalable, and keep your email sizes down. This method allows users to load images optionally into the email and is usually the fastest to load in their inbox.
However, you’ll need to host the images somewhere, and there can be privacy concerns with this, such as tracking user behavior through image loads.
Answer: Via an externally hosted URL on a Content Delivery Network
It’s almost always the best way, being cacheable, scalable, and keeping your email sizes down. It allows users to load images optionally into the email and is usually the fastest to load in their inbox.
Alternative answer: for smaller images, or where you don’t have access to an external server/CDN, Base64 encoding them inline is your best bet for cross-client support and reliability.
When it comes to embedding images in HTML emails, the method you choose will depend on your specific needs and constraints. For most cases, using an externally hosted URL on a CDN is the best option due to its performance and scalability benefits. However, for smaller images or when external hosting is not an option, Base64 encoding provides a reliable alternative. Inline attachments are generally less preferred due to their impact on email size and potential compatibility issues.
Choose the method that best fits your requirements and start sending beautiful, image-rich emails with MailPace today!
A detailed guide on building a pricing slider using Tailwind CSS and Alpine.js, with support for non-linear scaling, multiple currencies and custom price logic
Setting Up Multiple SMTP Transactional Email Providers, A Guide for Developers
A detailed guide on how emails are structured, focused on how headers and Multipurpose Internet Mail Extensions (MIME types) are used to structure the email
A guide to creating a simple Terminal Simulation in the browser using Tailwind CSS and JavaScript