Hello everybody,
I have a mail script written in python and now I want to add an ascending number in my script like this:
emailContent = "Text 1" + i+1 + "Text 2"
This is meant to be the information how many mails I have received. Can anyone help with this? This is my script:
I have a mail script written in python and now I want to add an ascending number in my script like this:
emailContent = "Text 1" + i+1 + "Text 2"
This is meant to be the information how many mails I have received. Can anyone help with this? This is my script:
#!/usr/bin/env python3 import smtplib import time f1 = open("../index/mail.txt","r") mail = f1.read() [:-1] f2 = open("../index/passwd.txt","r") passwd = f2.read() [:-1] f3 = open("../index/receiver.txt","r") receiver = f3.read() [:-1] #Email Variables SMTP_SERVER = 'smtp.gmail.com' #Email Server (don't change!) SMTP_PORT = 587 #Server Port (don't change!) GMAIL_USERNAME = mail #change this to match your gmail account GMAIL_PASSWORD = passwd #change this to match your gmail password class Emailer: def sendmail(self, recipient, subject, content): #Create Headers headers = ["From: " + GMAIL_USERNAME, "Subject: " + subject, "To: " + recipient, "MIME-Version: 1.0", "Content-Type: text/html"] headers = "\r\n".join(headers) #Connect to Gmail Server session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) session.ehlo() session.starttls() session.ehlo() #Login to Gmail session.login(GMAIL_USERNAME, GMAIL_PASSWORD) #Send Email & Exit msg = (headers + "\r\n\r\n" + content).encode('utf-8') session.sendmail(GMAIL_USERNAME, recipient, msg) session.quit sender = Emailer() sendTo = receiver emailSubject = "Debug" emailContent = "Text 1" + i+1 + "Text 2" #Sends an email to the "sendTo" address with the specified "emailSubject" as the subject and "emailConten$ sender.sendmail(sendTo, emailSubject, emailContent)