Skip to main content

send MIME message via SMTP server

Project description

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

Installation pip install SMTPEmail

Usage

Sending email via SMTP

>>>from SMTPEmail import SMTP
>>>client = SMTP(
			SMTP_server = <domain> or <IP_address>,
			SMTP_account = <account_name>,
			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'
					)

>>>print(client) #print the message

Subject: subject
From: John Doe <John.Doe@John.com>
To: Jane Doe <Jane.Doe@jane.com>
Date: Tue, 13 Nov 2018 17:52:01 +0800
Message-Id: 154210272151.1976.14038029430513051529@Jane.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="===============0340024224523524971=="

--===============0340024224523524971==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

hello world

--===============0340024224523524971==
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

<p>hello world</p>

--===============0340024224523524971==--

>>>client.send_msg()

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}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SMTPEmail-0.2.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

SMTPEmail-0.2-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page