Skip to main content

Build Status

A simple script to send MIME message via SMTP server and retrieve messages via POP3

Installation

pip install SMTPEmail

Install using Git

git clone https://github.com/Weizhang2017/SMTPEmail.git
cd SMTPEmail
python install setup.py

Usage

Sending email via SMTP
from SMTPEmail import SMTP
client = SMTP(
	SMTP_server=<domain> or <IP_address>,
	SMTP_account=<account_name>,
	SMTP_password=<SMTP_password>
	)
client.create_mime(
	recipient_email_addr='Jane.Doe@jane.com',
	sender_email_addr='John.Doe@john.com',
	subject='subject',
	sender_display_name='John Doe',
	recipient_display_name='Jane Doe',
	content_html='<p>hello world</p>',
	content_text='hello world'
)

client.send_msg()
Add customized email header
custom_header = {'Sender': 'john@abc.com'}
client.create_mime(
	recipient_email_addr='Jane.Doe@jane.com',
	sender_email_addr='John.Doe@john.com',
	subject='subject',
	sender_display_name='John Doe',
	recipient_display_name='Jane Doe',
	content_html='<p>hello world</p>',
	content_text='hello world',
	custom_header=custom_header
)

Retrieve email via POP3

messages will be returned in byte object

from SMTPEmail import POP3
client = POP3(
	POP3_server = <domain> or <IP_address>,
	POP3_account = <account_name>,
	POP3_password = <POP3_password>
)
msgs = client.retrieve_msg()

for msg in msgs:
	print(msg)

>>>print(client.mailbox_size())
{'message count': 804, 'mailbox size': 18096539}

Retrieve email via IMAP

from SMTPEmail import IMAP
client = IMAP(
	IMAP_server = <domain> or <IP_address>,
	IMAP_account = <account_name>,
	IMAP_password = <IMAP_password>
)
#you can select which mailbox to access and which email to retrieve by passing parameters 'mailbox_name' and 'msg_id'
for msg in client.retrieve_msg(mailbox_name='inbox', msg_id='1,3,5-8,11'):
    print(msg)
#'mailbox_name' and 'msg_id' are optional, the user will be promted to input the two parameters if either is missing
>>>msgs = client.retrieve_msg()
0. "INBOX"
1. "Templates"
...
Please select a mailbox:1
message id: 1 2 3 4 5 6 ...
Please select mail ID to retrieve email(e.g. 1-5,6,7): 1,3-6

Additonal features:

  1. Specify variable delete=True to delete the messages that have been retrieved, default value is False
  2. Specify variable msg_id='all' to retrieve all messages

Search emails via IMAP

Refer to RFC3501 for more search options

>>>for msg in client.retrieve_msg(mailbox_name='inbox', search_section='body', search_text='test_search'):
		print(msg)

Metadata

Release files for SMTPEmail 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for SMTPEmail 0.4.2
File Interpreter ABI Platform Actions
SMTPEmail-0.4.2-py3-none-any.whl Python 3 none any Details for SMTPEmail-0.4.2-py3-none-any.whl

Release files / SMTPEmail-0.4.2-py3-none-any.whl

Download URL SMTPEmail-0.4.2-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b4a5858626d354822113721fe5d37f4d449bea93b5664b9d7e20730282e41fb
BLAKE2b-256 checksum
How to use checksums
728ecbc9f439f8d7ac763728c31667b6ec524fe5bf15dced9120735c79fb1a49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.2

Security for SMTPEmail 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page