-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
31 lines (29 loc) · 870 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from os import environ
from dotenv import load_dotenv
import sandesh_py as sandesh
load_dotenv()
smtp_username = environ.get("SMTP_USERNAME")
smtp_password = environ.get("SMTP_PASSWORD")
smtp_host = environ.get("SMTP_HOST")
smtp_port = environ.get("SMTP_PORT")
if not (smtp_username and smtp_password and smtp_host and smtp_port):
print("No username and password found")
exit(1)
client = sandesh.SMTPClient(
smtp_host,
int(smtp_port),
{"username": smtp_username, "password": smtp_password},
# {"notls": True},
)
client.connect()
mail = sandesh.Mail(
{
"mailTo": "[email protected]",
"mailFrom": "[email protected]",
"subject": "Example Email",
"body": "This is demonstartaion of use of sandesh_py package",
"attachment": ["path/to/attachment"],
}
)
print(client.sendMail(mail))
client.close()