-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_mail.py
31 lines (24 loc) · 1.01 KB
/
send_mail.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
import yagmail
try:
from config import EMAIL_PASSWORD
yag = yagmail.SMTP("[email protected]", EMAIL_PASSWORD)
except Exception:
yag = yagmail.SMTP("[email protected]")
def send_mail(recipient="[email protected]", subject = "Stock API Update", body="test", attachment=[]):
global yag
yag.send(
to=recipient,
subject=subject,
contents=body,
attachments=attachment
)
def sold_stock_mail(symbol="JNUG", qty=1, price=1.00, trade="test.json"):
send_mail(subject=f"Sold {symbol} at {price}", body=f"Sold {qty} shares of {symbol} at {price}.\n{trade}")
def bought_stock_mail(symbol="JNUG", qty=1, price=1.00, trade="test.json"):
send_mail(subject=f"Bought {symbol} at {price}", body=f"Bought {qty} shares of {symbol} at {price}.\n{trade}")
def liquidate_stock_mail(trades):
send_mail(subject=f"Liquidated All Stocks", body=f"See trade below.\n{trades}")
if __name__ == "__main__":
recipient = "[email protected]"
body = "Hello there from Yagmail"
filename = "test.json"