What is a Transactional Email and What is It Used for?

Transactional emails: Types and Examples
Alex Kachalov Alex Kachalov 20 october 2022, 10:54 196109
For beginners

Remember when you created an account on a website and received an email to confirm your registration? The email triggered by your sign-up is a typical example of a typical example of a transactional email. This is the type of messages you receive in response to an action you take on a website or web application. Every internet user has received this type of email.

From this article, you’ll learn what transactional emails are, their types, and how to use them.

Transactional Email Definition

A transactional email is an email that is sent to an individual recipient following a commercial transaction or specific action performed by that person, such as a purchase in your connected store or a password reset request. They are an integral part of a product or service that a customer requests, so businesses don't need to obtain consent to send them.

You surely send these types of emails to customers if you run an online business. For example, if someone orders a product from your online store, you need to send an order confirmation. The confirmation is what assures the customer that the transaction will go as planned.

If you’re seeking a clear answer to the question “What is a transactional email?”, then you’ve come to the right place. We’re going to dive deeper into examples of this type of email and how it compares to a marketing email.

Transactional Emails vs. Marketing Emails

Transactional emails and marketing emails have different purposes in the customer interaction chain. The former is what you send to facilitate a transaction that a customer has already agreed to. On the other hand, marketing emails are what you send to promote your product and compel the recipient to initiate a transaction.

In most cases, you don't need permission from the recipient to send a transactional email, but you must obtain consent to send marketing emails. Any marketing email sent without consent constitutes spam, which can harm your brand’s reputation and your sending reputation.

Customers cannot unsubscribe from transactional emails, whereas you must provide a way for recipients to unsubscribe from marketing emails.

Transactional emails have higher engagement rates than marketing emails. This happens because such emails are initiated by the recipient, so they'll have to interact with them to complete a transaction. In contrast, marketing emails are initiated by the sender hoping to get the recipient’s attention — the recipient has nothing to lose by ignoring it.

It’s advisable for businesses to use separate sender addresses for transactional and marketing emails. If possible, you should also use separate IP addresses and domain names for each function. Doing so increases the chance that a transactional email will land in the user's primary inbox instead of the promotions tab.

Here are respective examples of transactional and marketing emails from a popular ridesharing app, Uber:

Example of a Transactional Email — Ride confirmation


Uber sends a confirmation email to each user after every completed trip. This email includes information about their fare and the distance covered. The confirmation email serves as a receipt confirming the recipient’s transaction with Uber.

Example of a Marketing Email — Start another trip


Uber also sends regular emails to customers compelling them to take additional trips. It often tosses in a time-limited discount to woo the customer to initiate the transaction.

Transactional Email Types

There are lots of different types of transactional emails. They range from the confirmation customers get when they order a product to an email that confirms an account registration and so on.

It’s vital to know how to send different types of transactional emails. That may seem hard, but many tools automate a lot of the work involved in sending them. One such tool is UniOne, which lets you create email templates and automatically send emails based on those templates when subscribers initiate a transaction. With UniOne, you can handle all transactional email activities from a single dashboard.

Some of the numerous types of transactional emails are described below.

Registration Email

A registration email is what you send when a user creates an account on your website or app. It could be an introductory email with links to guides and how-tos or anything else to draw the user’s attention.

This type of email goes a long way in keeping customers engaged with your platform. A new user that doesn’t get a registration email is more likely to forget about your website than those who do.

Tips for sending a registration email

  • Include details on how the recipient can sign into their account, such as a direct link to the login page. You can also include information about how the recipient can recover their account if they forget the details.
  • Provide links to articles and tutorials to help recipients get familiar with your platform. This can increase the chances of them engaging with your product.

Below is an example of a registration email from LastPass, a password management app.


Welcome Email

A welcome email is the first email that you send to a new customer. An exemplary case for this type of transactional email is when you run a newsletter. Any new subscriber to your newsletter should receive a welcome email thanking them for subscribing and letting them know what to expect from you.

A welcome email also usually follows a registration email – you’ll send it after a user has successfully created an account on your platform.

Tips for sending a good welcome email

  • Use compelling subject lines to get the recipient's attention and ensure they open the email.
  • Add links to content that tells the recipient more about your brand. For instance, if you run an online store, include links about offers that the recipient can take advantage of. 
  • Include a visible "unsubscribe" button at the footer that allows customers to opt out if they aren't interested in such emails.

Below is an example of a welcome email that Adobe sends to new subscribers to its Photoshop software suite. The Start now button takes recipients directly to their dashboard to start using the software.


Notification Email

These emails alert a user of a relevant action that happens on your platform. For instance, users should receive an email if there's an attempt to change their account credentials. This notification email keeps them in the loop about their activities on your website or application.

A good example of a notification email is what Instagram sends when someone attempts to log into your account. The platform sends a one-time pin to the email address associated with that account. It does this to ensure the login attempt is from you and not an unauthorized person.


Tips for sending this type of transactional email

  • Use a call-to-action button or link to direct the user toward the next step. This type of email constitutes a good opportunity to send users to your website.
  • Use your brand's unique colors, logo, and fonts to ensure recipients have a consistent experience.

Password Reset Email

You send a password reset email when a customer decides to change the password tied to their account on your website or application. This type of email should be simple. The focus should be a call-to-action button that takes customers to the web page where they can reset their password.

Password reset emails fall under notification emails, but we mentioned this one separately because of its importance.

Below is an example of a password reset email from GoDaddy.


Tips for sending this type of transactional email

  • Keep it concise and simple. Don’t include other unrelated things in the email.
  • Include the recipient’s name and a crystal-clear call-to-action button.
  • Place your logo prominently, so the recipient can recognize it.
  • Tell the recipient when the password reset link will expire. This will prevent unnecessary requests for your support team.

Order Confirmation Email

This is an email you send to notify the recipient of the completion of an online purchase. Examples include a receipt for a ride-sharing trip, a confirmation for purchasing an online ticket, or a confirmation for buying a set of books from an online vendor.

Below is a sample email confirming an order for a Kaspersky VPN subscription. The email includes relevant details like the order number, the date, and the exact price of the subscription.


Tips for sending this type of transactional email

  • Optimize the email for mobile viewing. Mobile optimization is crucial for every type of email but more so for this type because most people save their confirmation emails in their inboxes and review them from a mobile device.
  • You can encourage referrals by offering discounts or loyalty points to customers. A customer that just purchased something from you has a positive impression of your brand and is more likely to spread the word about it.
  • Point the recipient to helpful resources concerning the transaction you're confirming. For instance, if it’s a physical goods order, you can provide instructions on how to track its delivery.

Feedback Email

A feedback email requests a response from a user concerning a transaction they’ve made with your business. For instance, you could ask a user to leave a review if they had a good experience. You could also send a survey to your customers to help you know where to improve.

Below is a sample feedback email from Robinhood, a popular stock trading app. The email requests customers to fill out a survey letting Robinhood know if they're satisfied with its services. Note the prominent call-to-action button that says Tell us what you think.


Tips for sending this type of transactional email

  • Provide precise information about what you're requesting feedback for. This makes it easy for the customer to provide an honest review.
  • Send the email as quickly as possible after the transaction. Recipients are more likely to offer feedback on recent transactions than old ones.
  • Use a prominent call-to-action button to redirect the user to the page where they'll provide feedback.
  • Avoid including promotions or other unrelated messages in a feedback email. They can distract the customer and prevent them from offering feedback.

Shopping Cart Abandonment Email

This is an email you send to someone who added products from your store to their cart but didn't buy them. You can send reminder messages for the recipient to buy the products they abandoned in their cart. You could include a time-limited discount to motivate the recipient to complete the transaction.

Most big online retailers send abandoned cart emails. A considerable percentage of the recipients can complete the transaction from the email, especially if you include discounts to lure them.

Below is an example of a creative abandoned cart email from Home Alive Pets, a pet products retailer. Observe the unique messaging to draw the reader’s attention and the call-to-action button that redirects the user to their abandoned cart.


Tips for sending this type of transactional email

  • Offer discounts and perks to compel the recipient to complete the transaction.
  • Include a prominent call-to-action button that takes the user straight to their abandoned cart.
  • Send the email within the first 24 hours after the user abandons their cart. Recipients will more likely respond if the abandoned products are still fresh on their minds.

Back-In-Stock Email

You send this type of transactional email to notify customers of products that were previously sold out but are now available. The idea is to promote the products that are now in stock and get extra sales from the emails.

Tips for sending back-in-stock emails

  • Clearly state that the email is about back-in-stock items in the subject line. You can use phrases like "now available," "restocked," and "back on our shelves". These phrases will likely catch the recipient's attention.
  • Include discounts for individual products or bundles of the restocked products.
  • Use messaging that implies urgency. Let the customer know that that product can run out of stock again, so it's best to get them as fast as they can.
  • Include a button redirecting the user to the page of the restocked product(s).
  • If you sell clothing, use pictures of models to help your customers visualize the restocked products. High-resolution visuals play a big role in driving customers to buy a product.

Below is a sample back-in-stock email from clothing retailer Everlane. It’s visually appealing and simple. It sends a clear message that linen shirts are back in stock, with a Shop Now button that redirects the recipient to browse through them.


Thank-You Email

A thank-you email shows appreciation to a customer for completing a transaction. It could be a note thanking a customer when they make a purchase from your store. This type of message makes the customer feel esteemed and likely to purchase something from you in the future.

You can include a freebie as a courtesy in the thank-you email you send to customers. For instance, if you run a newsletter, you can include a free e-book for new subscribers. If you run an online store, you can include a discount code for future purchases.

Tips for writing this type of transactional email

  • Personalize the email by including the customer’s name.
  • Send it shortly after completing the transaction.
  • Keep it brief and professional. Use simple words.
  • Include links redirecting the recipient to your website or social media profiles.

Below is a sample thank-you email from Bank of America appreciating a customer for signing up for their online banking service. It includes a precise appreciation message and tips on how to proceed with the service.


Reminder Email

These are emails that nudge the recipient to carry out an action on your platform, especially one with a deadline. For instance, if a customer’s subscription has expired, you should send reminder emails for them to renew it or risk having their service canceled. It could also be a reminder for a subscriber to complete their account verification to unlock privileges on your website.

Tips for sending this type of transactional email

  • State the reminder clearly in the subject line. It can be “Hi, please verify your email!”, “Renew your subscription,” “Don’t let your domain expire,” etc.
  • Start the email with a friendly greeting, e.g., Hey Mike. A personalized greeting can retain the recipient’s attention.
  • Include a call-to-action button that redirects the user to where they can take care of what you’re reminding them about.
  • End with a formal closing. You can invite the customer to respond to the email or express gratitude for them reading the email up to the end.

Below is a sample reminder email from YouTube urging a user to renew their ad-free YouTube Premium account. Observe the Renew Now button that redirects customers to the payment page.


Added to Waitlist Confirmation Email

This is an email to send to a client to let them know that they've been added to the waitlist for a service. It also confirms the dates when the recipient was waitlisted. You could have a product that you haven’t launched yet but you’re building an email list for. The email list is the waitlist, and you should send a confirmation message to every address added to it.

Every address on the waitlist should also get a notification once you launch the awaited product.

Tips for sending this type of transactional email

  • Include the time frame for when the recipient can expect the product to launch. This riles up the recipient and makes them look forward to the launch.
  • Include a thank-you message for the recipient signing up to your waitlist.
  • Upsell existing products that the recipient can benefit from while waiting for the new one

Below is an example of a good added to waitlist confirmation email. It’s simple and goes straight to the point for the recipient.


Wishlist About to Go-Out-Of-Stock Email

A wish list is a collection of products people save to their account on an online store, including items they would like to buy someday or receive as a gift. You can send emails reminding your customers when the items in their wishlist are about to go out of stock. This type of transaction email creates a sense of urgency that compels the recipient to purchase the products.

The main tip for sending this type of email is to use a subject line that indicates a sense of urgency. It could be “Don’t let these items pass you by,” “Hurry, it’s about to go out of stock!,” “Don’t miss out on this opportunity,” etc.

Below is an example of this type of email from home appliance maker SharkNinja notifying the recipient of some products in their wishlist running out of stock.


Wishlist On Sale Email

This type of transactional email is similar to the one above. But here you’re notifying the customer of a discount on the items in their wish list. A recipient who sees this type of email gets a nudge to buy the items on their wish list before the discount runs out.

Many big online retailers tend to offer discounts on customers’ wishlists a while after they created them. It’s an effective marketing strategy that drives a significant percentage of the recipients to complete the purchase.

A good example of this type of email is the one below from home products retailer Hunting for George.


The main tips here are to use a catchy phrase in the subject line and include a button that redirects the recipient to their wish list to complete the purchase.

Win-Back Email

This is the email you send to inactive subscribers to compel them to re-engage with your platform. For example, if you run an online store, you can identify and reach out to customers who have not purchased anything in a long time. You could include a discount or free gift to persuade the customer to buy something again.

Tips for sending this type of transactional email

  • Use a creative subject line to draw the recipient's attention. Remember that they haven't interacted with your platform in a long time.
  • Send multiple win-back emails but space the timing to avoid spamming the recipient. You could send one weekly or monthly.
  • Don't wait too long after the customer disengages to send your reactivation email.

A good example of a reactivation email is from Duolingo, a language-learning app. If you signed up for Duolingo but haven’t logged into your account for a while, you’ll get an email reminding you about your language lessons. Observe the email’s simplicity, with the core focus being a call-to-action button that prompts you to sign in.



It’s necessary to know how to compose all types of transactional emails to engage customers. These emails are vital in generating revenue for your business, so you can’t ignore them. In our blog article we’ve introduced you to what transactional emails are and what they entail. We also stated the distinction between transactional and marketing emails and where you can use each one.

We provided ideal examples of every type of transactional email we mentioned and tips to help you write similar emails. Follow the tips above to create your unique and effective emails, and you’ll likely see an improvement in your email engagement with customers.

Another vital thing to consider is the platform you use to send your emails. An inferior email service can cause your emails to end up in spam folders where the recipients won’t see them. The good thing is that you can choose among many trusted transactional email platforms like UniOne.


Related Articles

For beginners
How to Send an Email with Python

Email notifications are essential for every business with an online presence. Over 4 billion active email users worldwide make it the best medium to reach customers. You can remind customers about important upcoming events, verify password changes, notify of login attempts, etc. Businesses use email to inform their customers of upcoming discounts and promotions to get higher sales.

Apart from sending emails manually, you may use programming languages like Python. This article will show how to implement the latter option. We’ll explain how sending emails via Python works and give you some good examples.

What email sending options do you have with Python?

The Simple Mail Transfer Protocol (SMTP) powers the massive flow of information exchange between email servers worldwide. Python supports the use of SMTP with a built-in smtplib module as part of its standard library. This module makes it easy to send emails via SMTP connections; it implements the standard RFC 821 (SMTP) and RFC 1869 (ESMTP) specifications and needs no extra installations to work.

You can use the smtplib module to automate sending transactional and bulk emails. It does not limit you to plain-text emails: you may also compose HTML messages and add attachments such as photos, PDF documents, etc.

Send emails via a third-party email service provider using API

From a programmer’s viewpoint, there’s hardly any difference between using your own SMTP server or the one provided by another party, be it your company’s IT department or an external service. However, operating your own SMTP servers makes you responsible for maintaining and securing them, which can be cumbersome and disruptive to your core business. Instead, you can choose an external email service provider (ESP) like UniOne to handle the task and make your life easier.

It should be noted that a good ESP usually offers two different ways to send emails. The most basic one is an SMTP API, which can be accessed using the same smtplib module mentioned above. The only difference is that you’ll need to specify the external server’s hostname and port instead of your own.

The second option is to use a specialized application programming interface, or API. This method does not rely on smtplib; instead, it uses the HTTP protocol to send commands to the ESP’s server. This method offers numerous advantages over the first one, but requires more complex programming.

In this article, we’ll show you the most essential examples using the smtplib module and Python on Windows. The same code will also work on Linux machines, but may require some fixes. If you need information about using the HTTP API, refer to the ESP’s documentation.

A step-by-step guide to sending emails with Python

How to send emails using a local SMTP server

A local SMTP server is a server that resides on your system. Typically you don't use it to send actual emails, but it will come handy if you need to check whether your Python script works correctly. You may install any popular server that is available for your OS. However, the easiest approach will be using an smtpd module that comes bundled with Python on Windows. Actually, it does not send your emails anywhere; it just outputs the message to your console, which is all you need for debugging.

To start smtpd, enter the following command at your command prompt:

python -m smtpd -c DebuggingServer -n localhost:2501

Now you have an instance of smtpd listening on port 2501. Let’s proceed with actual coding. Below is the most basic Python script to send an email from a local SMTP server:

import smtplib

sender = 'from@example.com'
receivers = ['to@example.com']
message = """From: Sender <from@example.com>
To: Addressee <to@example.com>
Subject: Test message #1

This is a test message for this UniOne tutorial on sending emails with Python.

    smtpObj = smtplib.SMTP('localhost', 2501)
    smtpObj.sendmail(sender, receivers, message)
    print("Successfully sent an email")
except SMTPException:
    print("Something has gone wrong")

Let’s take a closer look at the code. The first step is to import the smtplib module:


import smtplib


To send emails, we create an SMTP object:


smtpObj = smtplib.SMTP([host [, port]])


Provide the correct values for the above parameters:

  • host - This part refers to the hostname of your SMTP server. Use localhost as a host name if the server runs on your local machine.
  • port - Specifies the port number to use. It will be your local SMTP port number, or the one you’ve specified on the smtpd command line.

Now we have an open SMTP connection to the server, and may proceed with sending a simple email message. For this, the SMTP object has an instance method called sendmail(). This method requires three parameters:

  • sender − a string with the sender’s From address
  • receivers − a list of strings, one for each recipient’s address
  • message − a message formatted as specified in RFCs (note the two empty lines separating the headers section from the body)

Before calling this method, we enable the debugging mode for our SMTP object to see what’s happening when the script is run.

The next line checks whether an error has occurred while connecting to the server or sending a message. SMTPException is the base exception class for smtplib; for more sophisticated error processing, consult the module’s documentation.

Using an external SMTP server

The above example assumes you’re running an SMTP server locally on your PC. If not, you’ll need to modify the script accordingly, as described below.

When sending emails via SMTP, you’ll also want to encrypt the connection. Unencrypted connections can be intercepted by hackers looking to steal sensitive information. Encrypting prevents this problem.

For an encrypted connection, you’ll need this code to create an SMTP object:

smtpObj = smtpObj.SMTP_SSL(host, port)

This object is identical to smtplib.SMTP, but uses an implicit SSL connection to the server. For the host parameter, you specify your server's IP address or domain name. The port value defaults to 465, the standard for SMTP over SSL. For more information on secure connections, see our blog article.

When connecting to an external server, you’ll also need to properly introduce yourself. For this, the following method call is used:

smtpObj.login(username, password)

In the examples below, we’ll use one of the SMTP servers provided by UniOne. Connecting to our SMTP server is simple; you just need to use the proper connection parameters:

  • host: either smtp.us1.unione.io or smtp.eu1.unione.io (for accounts registered at us1.unione.io and eu1.unione.io, respectively).
  • port: 25, 465 or 587. You can use any of these ports; all our connections are encrypted by default, so you don't need to worry about that.
  • username: your account’s user_id or project_id (you can look up these parameters in your UniOne dashboard).
  • password: your account's API key or project_api_key.
  • encoding: use UTF-8.

For more things to note when using UniOne, see info on our SMTP API.

This is how the code will finally look like:

import smtplib

port = 465 
smtp_server = "smtp.us1.unione.io"
login = "123456789" # your UniOne user_id or project_id
password = "*******" # your UniOne API key or project_api_key

sender_email = "UniOne@example.com"
receiver_email = "recipient@example.com"
message = """From: Sender <from@example.com>
To: Addressee <to@example.com>
Subject: Test message #2

This is a test message sent from UniOne with Python using a secure connection.

    smtpObj = smtplib.SMTP_SSL(smtp_server, port)
    smtpObj.login(username, password)
    smtpObj.sendmail(sender, receivers, message) 
    print("Successfully sent an email")
except SMTPException:
    print("Something has gone wrong")

How to send HTML emails with Python

In the next example, we'll use the MIME message type that combines HTML/CSS and plain text. In Python, MIME messages are handled by the email.mime module.

It's advisable to write separate text and HTML versions of your email and merge them with the MIMEMultipart("alternative") Python object instance. This approach means that an email client can render your message in either HTML or text.

# Import the necessary components
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

port = 587 
smtp_server = "smtp.us1.unione.io"
login = "123456789" # your UniOne user_id or project_id
password = "*******" # your UniOne API key or project_api_key

sender_email = "UniOne@example.com"
receiver_email = "recipient@example.com"
message = MIMEMultipart("alternative")
message["Subject"] = "Multipart email test"
message["From"] = sender_email
message["To"] = receiver_email

# the plain text part
text = """\
Check out our new post on the UniOne blog about sending emails with Python:
We hope you learn a lot from it"""

# the HTML part
html = """\
      Check out our new post on the UniOne blog about sending emails with Python.</p>
    <p>We hope you learn a lot from it.</p>

# convert both parts to MIMEText objects and add them to the MIMEMultipart message
part1 = MIMEText(text, "plain")
part2 = MIMEText(html, "html")

# send your email
with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
        sender_email, receiver_email, message.as_string()

print('Message sent')

How to send emails with attachments

The next thing to learn is how to send emails with attachments using Python.

Python lets you attach text files, documents, images, videos, audio, etc. You just need to use the proper email class, such as email.mime.image.MIMEImage or email.mime.text.MIMEtext.

Keep in mind that the maximum total size for a UniOne email, including text and all attachments, is 10 MB.

import smtplib

# import the required modules
from email import encoders
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

port = 587 
smtp_server = "smtp.us1.unione.io"
login = "123456789" # your UniOne user_id
password = "*******" # your UniOne API key or project_api_key

subject = "How to send emails using Python"
sender_email = "UniOne@example.com"
receiver_email = "recipient@example.com"

message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = subject

# Add body to email
body = "This is a tutorial for sending attachments via Python"
message.attach(MIMEText(body, "plain"))

# Open PDF file in binary mode
filename = "PythonTutorial.pdf"
with open(filename, "rb") as attachment:
    # Create an attachment from your PDF file
    part = MIMEApplication(attachment.read())

# Add attachment to your message and convert it to string
part['Content-Disposition'] = 'attachment; filename="%s"' % filename
text = message.as_string()

# send your email
with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
        sender_email, receiver_email, text

Sending emails to multiple recipients with Python

You can send emails to multiple recipients using Python code via the UniOne API. As mentioned earlier, each recipient will receive separate email copies that will count toward your subscription.

Adding more recipients is simple; just type their address separated by commas and add CC and BCC. However, this method can be stressful if you're sending messages to thousands of addresses (you likely can’t type them all). The alternative is to place all the addresses in a CSV file and point the SMTP server to that database to fetch all them.


import csv, smtplib

port = 587 
smtp_server = "smtp.us1.unione.io"
login = "123456789" # your UniOne user_id
password = "*******" # your UniOne API key or project_api_key
sender = "UniOne@example.com"
message = """Subject: Read our tutorial for sending emails via Python
To: {recipient}
From: {sender}

Hi {name}, we have written a detailed tutorial for sending emails via Python"""

with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
    with open("contacts.csv") as file:
        reader = csv.reader(file)
        next(reader)  # skip the header row
        for name, email in reader:
                message.format(name=name, recipient=email, sender=sender)
            print(f'Sent to {name}')

For the above example, we have created a CSV file named “contacts.csv” with all the recipients’ names and addresses (put this file in the same folder as your Python script). This program instructs the server to read the file, fetch the email addresses, and send the email to each one.

Sending emails with images

You can send images by adding them as attachments to your emails with Python code. The best option is to add the image as a CID attachment (embedded it as a MIME object).


# import all necessary components
import smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart

port = 587 
smtp_server = "smtp.us1.unione.io"
login = "123456789" # your UniOne user_id
password = "*******" # your UniOne API key or project_api_key

sender_email = "UniOne@example.com"
receiver_email = "recipient@example.com"
message = MIMEMultipart("alternative")
message["Subject"] = "CID image testing"
message["From"] = sender_email
message["To"] = receiver_email

# write the HTML part
html = """\
   <img src="cid:UniOneImage">

part = MIMEText(html, "html")

# This code assumes that you saved the image file in the same directory as your Python script
fp = open('UniOneImage.jpg', 'rb')
image = MIMEImage(fp.read())

# Specify the ID according to the img src in the HTML part
image.add_header('Content-ID', '<UniOneImage>')

# send your email
with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
        sender_email, receiver_email, message.as_string()
print('Sent OK')

The above code illustrates attaching an image named “UniOneImage.jpg” that you’ve already saved in the same directory as your Python script. The program instructs the SMTP server to fetch and send the image to the recipients.


We have explained how to write Python scripts to send plain text emails, emails having attachments, and emails with multiple recipients. By following our tips, you can send messages easily via the UniOne SMTP API.

UniOne is a secure and reliable email service that guarantees high deliverability rates if you adhere to email regulations and best practices.

Valeriia Dziubenko
05 march 2024, 16:0413 min
For beginners
6 Ways Email Marketing Software Can Help Businesses Easily Reach the Right Leads
Email marketing tools have become a crucial part of digital marketing strategy. With email marketing software, businesses can easily reach their target audience, engage with more people, and even improve their lead generation efforts. 
Yurii Bitko
17 march 2023, 09:435 min
For beginners
What is a DNS MX record?
People send billions of emails daily, but most don’t know about the underlying infrastructure powering this massive information exchange. For example, how does your mail server know which computer will receive a message for a particular addressee? The answer is stored in the DNS database, and is known as a Mail Exchange (MX) record.
Alex Kachalov
15 december 2023, 12:354 min