🔒 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
  • 567
    Views
  • 2
    Participants
Last reply from:
Heizengberg

Online now

Members online
1,009
Guests online
1,256
Total visitors
2,265

Forum statistics

Threads
2,276,150
Posts
28,967,897
Members
1,231,139
Latest member
ayenluceno
Back
Top