🔒 Closed Auto sending email

Status
Not open for further replies.
Code:
import smtplib
import datetime

now = datetime.datetime.now().strftime("%H:%M:%S")
weekday = datetime.datetime.today()

def send_email(subject, msg):
 try:
  if weekday == 0 or weekday == 3:
   server = smtplib.SMTP('smtp.gmail.com:587')
   server.ehlo()
   server.starttls()
   server.login(email_add, password)
   message = 'Subject: {}\n\n{}'.format(subject,msg)
   server.sendmail(email_add,email_add,message)
   server.quit()
   print("Success: Email sent!")
 except:
   print("Email failed to send")

subject = "Test email!"
msg = "Hello there ! this is python"

email_add = ""
password = ""

send_email(subject, msg)


Gusto ko po kasi mag send tong script ng email sa sinet kung date pero wala akong natatanggap.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 3
    Replies
  • 584
    Views
  • 2
    Participants
Last reply from:
Heizengberg

Trending Topics

Online now

Members online
1,239
Guests online
1,659
Total visitors
2,898

Forum statistics

Threads
2,286,357
Posts
29,037,321
Members
1,217,900
Latest member
Johnnynattsville
Back
Top