from datetime import date
import datetime
import time
import smtplib
import os
import sys
import mysql.connector
import commands
import xlwt
import pandas.io.sql as sql
from email.mime.multipart import MIMEMultipart
from mysql.connector import Error
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
class Sendmail:
def __init__(self):
print("Sending mail ......")
cc = ['purval1992@gmail.com']
fromaddr="alert@trakzee.com"
today = date.today()
if not os.path.exists('mycontacts1.txt'):
os.system('echo "mail@gmail.com" >mycontacts1.txt')
with open("mycontacts1.txt", "r") as a_file:
for line in a_file:
toaddr = line.strip()
print("Sending mail to " + toaddr)
s = smtplib.SMTP('smtp-server-address', 587)
s.starttls()
s.login("smtp-server-username","smtp-server-password")
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "attachment mail"
body = 'this mail is for testing'
msg.attach(MIMEText(body, 'plain'))
filename = "test.txt"
filepath = "/home/script/test.txt"
attachment = open(filepath, "rb")
p = MIMEBase('application', 'octet-stream')
p.set_payload((attachment).read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
msg.attach(p)
text = msg.as_string()
toaddrs = [toaddr] + cc
s.sendmail(fromaddr, toaddrs, text)
s.quit()
dataf = Sendmail()
dataf
Subscribe to:
Posts (Atom)
Run first C# Program in ubuntu and create linux command
Got it — here’s how to go from zero to running C# on Linux in a clean, beginner-friendly way. 1. Install .NET SDK The .NET SDK is ...
-
Epson LQ 300 Printer Driver for Linux (Dot Matrix Printer) 1. Download the ppd file from the below link https://raw.githubusercontent.com...
-
an authentication error has occurred the token supplied to the function is invalid I have installed xrdp 0.9.8 at server side. Re...
-
First check partition type of existing disk. parted -l To convert MBR to GPT, create one partition with gpt and that will convert entire...
No comments:
Post a Comment