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:
Comments (Atom)
Kubernetes Cluster Security - Starting 2026 the Right Way 🛡️
Sooooo finally writing the first blog of 2026 — and what better topic to kick things off than Kubernetes cluster security . Kubernetes has...
-
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...
-
Steps for installing GtkDialog in ubuntu 1. Download tar from below link https://drive.google.com/open?id=0BwPBGrPmbppAaHIzVWdPbU04RUE...

No comments:
Post a Comment