How to set up email forwarding

How to set up email forwarding
Yurii Bitko Yurii Bitko 20 november 2023, 14:16 203
For beginners

How to Set Up Email Forwarding

Email forwarding can help you boost your productivity. It can reduce the number of emails you check daily and save time you can use elsewhere.

This article will explain how to set up mail forwarding in Gmail, Outlook, Yahoo, Apple Mail, and AOL.

What Is Automatic Email Forwarding?

Email forwarding is the process of redirecting messages from your inbox to a new address you have specified. For instance, most people have separate emails for personal and business use. You may need to forward messages automatically from your work address to your personal one while on vacation so that you don’t miss anything urgent.

Most email providers offer this feature, and it’s usually pretty easy to set up. Read on to learn how to set up mail forwarding for the most popular email services.

How to Set Up Gmail Automatic Forwarding

Gmail makes it very easy to forward emails automatically. Here’s how you set up Gmail email forwarding:

    1. Open Gmail.com and log into the account you want to forward messages from.
    2. Click on the Settings icon from the top menu.
    3. Tap See All Settings

    1. Click on the Forwarding and POP/IMAP tab in the top menu.

    1. Tap the Add a Forwarding Address button.

  1. Type the email address to which you want to forward messages and click Next > Proceed > OK.
  2. Google will send a verification message with a unique link to your typed address. Click on the link to verify the request.
  3. Return to your Gmail account and go to Settings > See All Settings > Forwarding and POP/IMAP.
  4. Tap Forward a Copy of Incoming Mail To. Then, choose what you want to happen to the forwarded messages. You can keep them in your original mailbox or immediately delete them after forwarding.
  5. Tap Save Changes.

How to Set Up Outlook Automatic Forwarding

Setting up automatic forwarding in Outlook is very similar to that of Gmail. Follow these steps to set up automatic forwarding for an Outlook email address.

    1. Head to Outlook.com and log into the email account you want to forward messages from.
    2. Tap the Settings icon in the top right corner.
    3. Tap View all Outlook Settings.

    1. Tap Mail > Forwarding and check the Enable Forwarding box.

  1. Type the email address you want to forward messages to. Check the box below if you’d like to keep copies of forwarded messages in your mailbox.
  2. Click Save.

How to Set Up Yahoo Mail Automatic Forwarding

Automatic forwarding setup on Yahoo Mail is similar to the process for Gmail and Outlook. However, this feature is only available to Yahoo Mail Plus subscribers, unlike other mailbox providers offering it for free.

Yahoo Mail Plus costs US$5 per month. It removes ads from your inbox and gives you access to premium features. Follow these steps to activate email forwarding:

    1. Go to Yahoo.com and log into the account you want to forward emails from.
    2. Click on the Settings icon in the top-right corner.
    3. Tap More Settings.

  1. Tap Mailboxes.
  2. Look at the Mailbox List, and choose the email address you want to set up forwarding for (your current address).
  3. Scroll down and tap Forwarding. Enter the email address you wish to deliver your messages to.
  4. Click Verify. Yahoo will send a verification email to the address you’ve entered. Log into that email address and follow Yahoo’s verification instructions. After verification, messages will be automatically forwarded from your original Yahoo email address to the one you specified.

How to Set Up Apple Mail Automatic Forwarding

You can set up automatic forwarding on Apple Mail (iCloud) by following the steps below. Again, the process is pretty straightforward.

    1. Head to iCloud.com and log into your email account.
    2. Click on the Settings icon in the top-left corner and Tap Settings.

    1. Tap Mail Forwarding
    2. Choose Forward my email to and enter the email address you want to forward messages to.

  1. Choose whether to Delete messages after forwarding.
  2. Close the Settings menu to save your changes.

How to Set Up AOL Automatic Forwarding

Setting up automatic forwarding on an AOL email address is easy. Before following the steps below, ensure you set your inbox view to Classic.

  1. Head to aol.com and log into your email account.
  2. Click on the Settings icon.
  3. Click on General Settings.
  4. Click Forwarding > Forward a Copy of Incoming Mail to.
  5. Enter the email address you want to forward messages to.
  6. Tap Save Changes.

However, note that automatic forwarding is only available to AOL premium users.

Tips and Best Practices to Manage Forwarded Emails

You’ve learned how to set up automatic email forwarding on different email services. As you can observe, the process is quite similar for all popular email providers. The steps are easy to follow; we have explained what to do in detail.

Most email providers offer automatic forwarding for free users. Yahoo and AOL are the exceptions that allow it on premium accounts only.

Now, let’s examine the tips and best practices to manage your forwarded emails effectively and ensure they don’t overwhelm your inbox.

Organize Your Emails With Labels

You can create labels for different types of emails to keep your inbox organized. For example, you can create educational, work, personal, and shopping labels.

You can then choose the exact one that any message from a specific address should be classified under, e.g., any message from a work address ends up in the work label.

You can sort your inbox using labels at any time. They help you organize your messages and reply to them more efficiently. You can even assign multiple labels to a single email for extra flexibility.

Use Filters

For more sophisticated email management, set up filters for incoming mail if your mail client supports this feature. Filters are applied to all incoming mail automatically. Using filters allows for more precise sorting of your messages. You can assign labels to your messages based on sender address or certain keywords, archive them or put them into your custom folders.

Review Your Settings Frequently

Don’t just set up automatic forwarding and then abandon your settings. You should constantly review your forwarding setup to ensure you only receive relevant emails.

Conclusion

Automatic email forwarding offers many benefits. It ensures a steady information flow within a team, enabling you to read every message, even when communicating from multiple email addresses.

We have explained how to set up email forwarding in the most popular email clients, including Gmail, Outlook, Yahoo Mail, Apple Mail, and AOL. The steps are easy to follow, and you shouldn’t face problems setting up automatic forwarding on your email account.

FAQs on Automatic Email Forwarding

Can you automatically forward emails?

Yes, most mailbox providers allow you to set up automatic email forwarding. Every message coming into your inbox will be automatically forwarded to another email address.

How do you set up automatic email forwarding?

On your Settings page, you’ll provide an email address to which your email client should forward every incoming message. Any incoming email will automatically be transferred to the specified address.

Do auto-forwarded emails appear in sent items?

Yes, you can choose whether your auto-forwarded emails should still appear in your sent inbox, or you’d rather have them deleted immediately after forwarding.

Related Articles

Blog
For beginners
Email Length & Attachment Size Limit or Email
Some important tips to optimize your email
Yurii Bitko
20 july 2022, 12:437 min
Blog
For beginners
Tips for Making Your Transactional Emails More Personal
Learn how to create a personalized email.
Denys Romanov
27 october 2021, 15:248 min
Blog
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.
"""

try:
    smtpObj = smtplib.SMTP('localhost', 2501)
    smtpObj.setdebuglevel(1)
    smtpObj.sendmail(sender, receivers, message)
    smtpObj.quit()      
    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.
"""

try:
    smtpObj = smtplib.SMTP_SSL(smtp_server, port)
    smtpObj.login(username, password)
    smtpObj.sendmail(sender, receivers, message) 
    smtpObj.quit()        
    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 = """\
Hi,
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 = """\
<html>
  <body>
    <p>Hi,<br>
      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>
  </body>
</html>
"""

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

# send your email
with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
    server.sendmail(
        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())
    attachment.close()

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

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

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.

Input:

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:
            server.sendmail(
                sender,
                email,
                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).

Input:

# 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 = """\
<html>
 <body>
   <img src="cid:UniOneImage">
 </body>
</html>
"""

part = MIMEText(html, "html")
message.attach(part)

# 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())
fp.close()

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

# send your email
with smtplib.SMTP_SSL(smtp_server, port) as server:
    server.login(login, password)
    server.sendmail(
        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.

Conclusion

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