Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #DEBIAN
- #python3 -m venv /usr/src/skri/
- #mcedit /usr/src/skri/skri.py
- #source /usr/src/skri/bin/activate
- #pip install requests
- #cd /usr/src/skri/
- #python3 /usr/src/skri/skri.py
- #Windows
- #python -m venv D:\projects\pochta
- #cd D:\projects\pochta
- #D:\projects\pochta\Scripts\activate
- #pip install requests
- #python skri.py
- from base64 import b64decode
- import requests
- import smtplib
- from os.path import basename
- from email.mime.application import MIMEApplication
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- from email.utils import COMMASPACE, formatdate
- import re
- def send_mail(files=None, notification=""):
- sender_address = '[email protected]'
- sender_pass = 'takxkccccccccc'
- receiver_address = ["[email protected]", "[email protected]"]
- mail_content = notification + "\n" + '''See attachements
- &
- &&/ ##(&%
- #((&&&/((&&
- &/(#&&/((((&(
- &///&//((((#&&%
- &//((((((((((((&(/&
- &/(/%(((((((((((((&((/&
- &//(/&&. &(((((((((((((((/&/
- &//((/& &((((((&&%(((&#&&&
- &//(((/& &((((((&(((((((&&&(///&
- &//((((((((((((((((((&&((((((((((&&&&&&
- ,%//(((((((((((((((((((((&/(((((((((&#((&%
- &//(((((((((((((((((((&&&&&&/((((((((&((%@
- &/(%&&(((((((((((((((&& &/((((((&(
- &/((&(((((((((((((((&& &&((((((((&&
- &(((((((((((((&&&&&& &///(((((&&
- &((((((((((&&&&& &&/(((((&&
- &&#((((&&& &//((((&&&
- &&&/(((((&&
- &&&&/
- '''
- msg = MIMEMultipart()
- msg['From'] = sender_address
- msg['To'] = ", ".join(receiver_address)
- msg['Date'] = formatdate(localtime=True)
- msg['Subject'] = 'Notification from server'
- msg.attach(MIMEText(mail_content, 'plain'))
- for f in files or []:
- with open(f, "rb") as fil:
- part = MIMEApplication(
- fil.read(),
- Name=basename(f)
- )
- # After the file is closed
- part['Content-Disposition'] = 'attachment; filename="%s"' % basename(f)
- msg.attach(part)
- session = smtplib.SMTP('smtp.yandex.ru', 587)
- session.starttls() #enable security
- session.login(sender_address, sender_pass) #login with mail_id and password
- text = msg.as_string()
- session.sendmail(sender_address, receiver_address, text)
- session.quit()
- print('Mail Sent')
- send_mail(["D:/projects/pochta/skri.py"], "Privet")
Add Comment
Please, Sign In to add comment