# PyEmailHandler
Receive and Send emails at ease.
Intended for quick and easy projects that does not require specific function other than to receive, send and reply to emails.
**Supports:**
* IMAP4
* SMTP
## Basic Usage:
### Send a simple Email
```py
from PyEmailHandler import EmailSMTP
email = EmailSMTP(
username="smtp_username",
password="smtp_password",
sender_mail="sender@example.com",
sender_name="WeSend",
smtp_server="smtp.example.com",
port = 587,
protocol = "starttls"
)
email.start_connection()
email.send(
receiver="recipient@mailaddress.com",
subject="Subject of the e-mail",
body="Content of the e-mail, can be as long as you want"
)
```
### Send a comprehensive Email
```py
from PyEmailHandler import EmailSMTP
email = EmailSMTP(
username="smtp_username",
password="smtp_password",
sender_mail="sender@example.com",
sender_name="WeSend",
smtp_server="smtp.example.com",
port = 587,
protocol = "starttls"
)
email.start_connection()
message = MIMEText(html_text, 'html')
message['Subject'] = "Main subject"
message['To'] = "Recipient Name <recipient@mailaddress.com>"
message['From'] = "WeSend <sender@example.com>"
email.send_raw(
receiver="recipient@mailaddress.com",
mime=message
)
```
### Receive Inbox
```py
from PyEmailHandler import EmailIMAP
inbox = EmailIMAP(
username="imap_username",
password="imap_password",
imap_server="imap.example.com",
port=993,
protocol="ssl"
)
inbox.start_connection()
mails = inbox.get_mails()
for mail in mails:
print(mail)
```
### Reply to an inbox
By combining Both IMAP and SMTP functionalities
```py
from PyEmailHandler import EmailIMAP, EmailSMTP
from PyEmailHandler.tools import reply_mail
inbox = EmailIMAP(
username="imap_username",
password="imap_password",
imap_server="imap.example.com",
port=993,
protocol="ssl"
)
inbox.start_connection()
smtp = EmailSMTP(
username="smtp_username",
password="smtp_password",
sender_mail="sender@example.com",
sender_name="WeSend",
smtp_server="smtp.example.com",
port = 587,
protocol = "starttls"
)
smtp.start_connection()
mails = inbox.get_mails()
for mail in mails:
if mail == "Some Criteria here":
message = MIMEText("Body of Message goes here", "plain")
#Other headers are handled automatically only the body of the message is required.
#Some headers are not automatically handled such as the Reply-To header which might be important
reply_mail(smtp, mail, message)
```
PROTOCOLS:
```py
ssl
starttls
none #This is unsecure mode, use it at your own discretion
```
Raw data
{
"_id": null,
"home_page": null,
"name": "PyEmailHandler",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "python, sockets, networking, communication",
"author": null,
"author_email": "BrewedCoffee <support@kinuseka.us>",
"download_url": "https://files.pythonhosted.org/packages/f1/8c/db5cceadb69dd65a1445dabadf9e3d48e86f3b2f8a80b50d0a26f97e72bf/pyemailhandler-0.1.3a0.tar.gz",
"platform": null,
"description": "# PyEmailHandler\r\n\r\nReceive and Send emails at ease. \r\n\r\nIntended for quick and easy projects that does not require specific function other than to receive, send and reply to emails.\r\n\r\n**Supports:**\r\n* IMAP4\r\n* SMTP\r\n\r\n## Basic Usage: \r\n\r\n### Send a simple Email\r\n```py\r\nfrom PyEmailHandler import EmailSMTP\r\nemail = EmailSMTP(\r\n username=\"smtp_username\",\r\n password=\"smtp_password\",\r\n sender_mail=\"sender@example.com\",\r\n sender_name=\"WeSend\",\r\n smtp_server=\"smtp.example.com\",\r\n port = 587,\r\n protocol = \"starttls\"\r\n )\r\nemail.start_connection()\r\nemail.send(\r\n receiver=\"recipient@mailaddress.com\",\r\n subject=\"Subject of the e-mail\",\r\n body=\"Content of the e-mail, can be as long as you want\"\r\n)\r\n```\r\n\r\n### Send a comprehensive Email\r\n```py\r\nfrom PyEmailHandler import EmailSMTP\r\nemail = EmailSMTP(\r\n username=\"smtp_username\",\r\n password=\"smtp_password\",\r\n sender_mail=\"sender@example.com\",\r\n sender_name=\"WeSend\",\r\n smtp_server=\"smtp.example.com\",\r\n port = 587,\r\n protocol = \"starttls\"\r\n )\r\nemail.start_connection()\r\nmessage = MIMEText(html_text, 'html')\r\nmessage['Subject'] = \"Main subject\"\r\nmessage['To'] = \"Recipient Name <recipient@mailaddress.com>\"\r\nmessage['From'] = \"WeSend <sender@example.com>\"\r\nemail.send_raw(\r\n receiver=\"recipient@mailaddress.com\",\r\n mime=message\r\n)\r\n```\r\n\r\n### Receive Inbox\r\n```py\r\nfrom PyEmailHandler import EmailIMAP\r\ninbox = EmailIMAP(\r\n username=\"imap_username\",\r\n password=\"imap_password\",\r\n imap_server=\"imap.example.com\",\r\n port=993,\r\n protocol=\"ssl\" \r\n )\r\ninbox.start_connection()\r\nmails = inbox.get_mails()\r\nfor mail in mails:\r\n print(mail)\r\n```\r\n\r\n### Reply to an inbox\r\nBy combining Both IMAP and SMTP functionalities\r\n```py\r\nfrom PyEmailHandler import EmailIMAP, EmailSMTP\r\nfrom PyEmailHandler.tools import reply_mail\r\ninbox = EmailIMAP(\r\n username=\"imap_username\",\r\n password=\"imap_password\",\r\n imap_server=\"imap.example.com\",\r\n port=993,\r\n protocol=\"ssl\" \r\n )\r\ninbox.start_connection()\r\nsmtp = EmailSMTP(\r\n username=\"smtp_username\",\r\n password=\"smtp_password\",\r\n sender_mail=\"sender@example.com\",\r\n sender_name=\"WeSend\",\r\n smtp_server=\"smtp.example.com\",\r\n port = 587,\r\n protocol = \"starttls\"\r\n )\r\nsmtp.start_connection()\r\n\r\nmails = inbox.get_mails()\r\nfor mail in mails:\r\n if mail == \"Some Criteria here\":\r\n message = MIMEText(\"Body of Message goes here\", \"plain\")\r\n #Other headers are handled automatically only the body of the message is required.\r\n #Some headers are not automatically handled such as the Reply-To header which might be important\r\n reply_mail(smtp, mail, message)\r\n```\r\n\r\nPROTOCOLS:\r\n```py\r\nssl\r\nstarttls\r\nnone #This is unsecure mode, use it at your own discretion\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A simplified tool for mailing services",
"version": "0.1.3a0",
"project_urls": {
"homepage": "https://gitlab.com/brewedcoffee/PyEmailHandler"
},
"split_keywords": [
"python",
" sockets",
" networking",
" communication"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7b143bb2fe857674f931974b4c0ec55436ef65b93d946a116c2d80d0ca089fa1",
"md5": "6f7c6b0f7ff9ddc7f53c7f8021c31924",
"sha256": "e2afc1083b28bcd30795ee7532a4d2134c86ed8e1749be61afb7fa5c4dc6dbef"
},
"downloads": -1,
"filename": "PyEmailHandler-0.1.3a0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6f7c6b0f7ff9ddc7f53c7f8021c31924",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6530,
"upload_time": "2024-07-26T01:10:51",
"upload_time_iso_8601": "2024-07-26T01:10:51.074914Z",
"url": "https://files.pythonhosted.org/packages/7b/14/3bb2fe857674f931974b4c0ec55436ef65b93d946a116c2d80d0ca089fa1/PyEmailHandler-0.1.3a0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f18cdb5cceadb69dd65a1445dabadf9e3d48e86f3b2f8a80b50d0a26f97e72bf",
"md5": "89235bfb35971645ed2afcab4ae50fb4",
"sha256": "a31d1b75be818df155cd25f360b7a041a9bdef0c0200864a771fa9c9efada09a"
},
"downloads": -1,
"filename": "pyemailhandler-0.1.3a0.tar.gz",
"has_sig": false,
"md5_digest": "89235bfb35971645ed2afcab4ae50fb4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5807,
"upload_time": "2024-07-26T01:10:53",
"upload_time_iso_8601": "2024-07-26T01:10:53.022508Z",
"url": "https://files.pythonhosted.org/packages/f1/8c/db5cceadb69dd65a1445dabadf9e3d48e86f3b2f8a80b50d0a26f97e72bf/pyemailhandler-0.1.3a0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-26 01:10:53",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "brewedcoffee",
"gitlab_project": "PyEmailHandler",
"lcname": "pyemailhandler"
}