hello i just bought custom email address from namecheap. i am trying to figure out how to send emails automatically. this is my code:
import smtplib #socket
from email.mime.text import MIMEText
sender_email="[email protected]"
password = "password"
smtp_host="mail.privateemail.com"
#socket.gaierror,smtplib.SMTPAuthenticationError:
def send_mail(send_to,subject,content):
with smtplib.SMTP(smtp_host,587) as smtp:
smtp.starttls()
smtp.login(user=sender_email,password=password) #socket.gaierror,smtplib.SMTPAuthenticationError:
message = MIMEText(f'{content}')
message['subject'] = subject
message['to'] = send_to
try:
smtp.sendmail(sender_email,send_to, msg=message.as_string())
except Exception or ExceptionGroup as e:
print(f"E: {e}")
send_mail(send_to="[email protected]",subject="subject",content="description here.")
but it doesn't send anything nor prints any error in console. it works fine with outlook.
what should have happened: it should send email to specified email. what actually happened: it doesn't send email nor prints anything on console.