Git Product home page Git Product logo

python-email-autoresponder's Introduction

Python E-Mail Autoresponder

Simple python script that connects to a mail server via IMAP and SMTP and replies to all emails in the inbox coming from a certain sender address using the Reply-To header. Mails that have been replied to are deleted afterwards.

Dependencies

This script runs on python3 and is written for the purpose of running as a cronjob.

To run it you'll only need python3.

Installation

To install, simply download a copy of the project (see screenshot below) and extract it to whatever folder you like.

Github Archive Download

Alternatively, on UNIX systems you can run

wget https://github.com/sunborn23/python-email-autoresponder/archive/master.zip && unzip master.zip

to download and then extract all project files.

Configuration

Before first run, you need to adapt the project to your needs by editing the autoresponder.config.ini file with a text editor.

The required configuration items for the individual sections are listed below.

Section [login credentials]

Configuration Item Description
mailserver.incoming.username The username to use for logging in at the IMAP server hosting the inbox, usually an email address.
mailserver.incoming.password The password to use for logging in at the IMAP server hosting the inbox.
mailserver.outgoing.username The username to use for logging in at the SMTP server for sending the reply, usually an email address.
mailserver.outgoing.password The password to use for logging in at the SMTP server for sending the reply.
mailserver.outgoing.display.name The name to use in the email's "From" field indicating where the reply email is from.
mailserver.outgoing.display.mail The email address to use in the email's "From" field, should normally be a no-reply address.

Section [mail server settings]

Configuration Item Description
mailserver.incoming.imap.host The hostname, domain or IP of the IMAP server hosting the inbox.
mailserver.incoming.imap.port.ssl The port to use for SSL communication with the IMAP server.
mailserver.outgoing.smtp.host The hostname, domain or IP of the SMTP server for sending the reply.
mailserver.outgoing.smtp.port.tls The port to use for TLS communication with the SMTP server.
mailserver.folders.inbox.name The name of the inbox folder, normally this is "Inbox".

Section [mail content settings]

Configuration Item Description
mail.request.from The sender email address to check new mails against. If an email is found in the inbox with this sender address, a reply is triggered.
mail.reply.subject The subject line of the reply email.
mail.reply.body The plain text body of the reply email.

After configuring the project, you can run it manually to test if your configuration works.

Manual Usage

For testing purposes you can run the script from the shell. To do so, navigate to the project directory and run

python3 run_autoresponder.py

If you want to run the script multiple times with different configurations on each executions, you can achieve that by running

python3 run_autoresponder.py --config-path /the/path/to/your/config/file/autoresponder.config.ini

Usage as a cronjob

For production use you can configure it as a cronjob.

From the shell, run:

crontab -e

Then append to the file (replace "/the/path/to/the/project/folder" by the actual path to these files):

*/1 * * * * python3 /the/path/to/the/project/folder/run_autoresponder.py

This will run the script every minute.

You can use any Online Cron Expression Generator for generating other cron expressions.

For info on how to craft the cron expression yourself, run man crontab.

python-email-autoresponder's People

Contributors

sunborn23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-email-autoresponder's Issues

How to reply to an email using smtp?

Hi! I came across your work while working on sending an email reply using python. I tried searching through stackoverflow for the same, but that was not helpful. I tried using your program and saw that it replies to the sender emails. My main queries are regarding the same.

  1. How to reply to an email. i.e. should we use the email object for the same.
  2. What all packages should we import for the same.
  3. could you share a small snippet of example code regarding the same.

Your help on the same would be much appreciated.
Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.