How to Host Email Images on Your Server and Update Image URLs in HTML Emails

Email & Newsletter Image hosting on server

In email development, images are an essential part of creating engaging and visually appealing email campaigns. However, instead of embedding images directly in the email body (which can lead to size issues and slow loading times), it’s a best practice to host them on your own server or a reliable external server and link to those images using URLs.

This blog will guide you through the process of hosting email images on your server and updating the image URLs in HTML emails.


Why Host Images on a Server?

  1. Improved Performance: Hosting images on your server allows better control over the image’s loading time. You can use optimized formats like WebP or compress images to reduce their size.
  2. Branding Control: You maintain control over your assets and can ensure the images appear as intended, without relying on third-party email servers.
  3. Better Tracking: Hosting on your own server enables you to track and manage requests for the images, providing valuable data for analytics.


Step 1: Upload Images to Your Server

First, you need to upload the images to your web server or a hosting service (such as AWS S3 or a CDN if you need more scalability).

  1. Login to your server: Use FTP, SSH, or your hosting platform’s file manager.
  2. Choose a folder: Organize your images in a dedicated folder like /images/ to keep everything neat.
  3. Upload the images: Select the images and upload them to the folder.


Once uploaded, your images will have URLs like this:

https://yourwebsite.com/images/image1.jpg


Step 2: Update Image URLs in the HTML Email

Now, you need to link the images within the email content using the URLs you’ve just created.

  1. Open the HTML email template: In your email template, locate the <img> tags where images are used.
  2. Update the src attribute: Replace the src value with the full URL of the image on your server.


For example, if you uploaded image1.jpg, your HTML <img> tag should look like this:

<img src="https://yourwebsite.com/images/image1.jpg" alt="Your Image Description" />


Step 3: Test the Email

Testing is crucial to ensure that the images load correctly in different email clients (like Gmail, Outlook, etc.).

  1. Send a test email: Make sure the images appear correctly.
  2. Check the load time: Ensure the images load without any significant delay.
  3. Test on multiple devices: Images might look different on mobile devices compared to desktops, so check for responsiveness.


Step 4: Optimize Images

To ensure the best performance, consider the following optimization techniques:

  • Compression: Use tools like TinyPNG or ImageOptim to reduce file sizes without sacrificing quality.
  • Responsive Images: Use the srcset attribute to provide multiple image sizes, ensuring they look good on different screen resolutions.
  • WebP Format: Consider using WebP format for smaller file sizes and faster loading, but ensure that your email clients support it.


Final Thoughts

By hosting images on your server and linking to them through URLs in your email code, you can improve the performance and branding of your email campaigns. This method also gives you greater control over your images, and it ensures that your recipients get the best viewing experience.

Happy coding!

Picture of Nilesh Sarode

Nilesh Sarode

Hi, I’m Nilesh, a Freelance Front-End Development Practice Lead and UX Developer at Magnetas. I combine thoughtful design with responsive, semantic code to create seamless user experiences. With expertise in email campaign design, I focus on delivering innovative solutions that work across all devices and adapt to the ever-changing front-end landscape. Feel free to get in touch for a free consultation to discuss your design challenges or new projects!

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe for more..

Whatsapp-color Created with Sketch. Chat