0

here is my code:

import smtplib 

from email import encoders
from email.mime.text import MIMEText 
from email.mime.base import MIMEBase 
from email.mime.multipart import MIMEMultipart 

server = smtplib.SMTP('smtp.gmail.com', 25)

server.ehlo()

with open('password.txt', 'r') as f:
    password = f.read()

server.login('bjdawson1012@gmail.com', password) 

msg = MIMEMultipart()
msg['from'] = 'BenDawson'
msg['To'] = 'bdawsonceo@gmail.com'
msg['Subject'] = 'DawsonUTV'

with open('message.txt', 'r') as f:
    message = f.read()

msg.attach(MIMEText(message, 'plain'))

filename = 'baldksi.jpg'
attachment = open(filename, 'rb')

p = MIMEBase('application', 'octet-stream')
p.set_payload(attachment.read())

encoders.encode_base64(p)
p.add_header('Content-Disposition', f'attachment; filename ={filename}')
msg.attach(p)

text = msg.as_string()
server.sendmail('bjdawson1012@gmail.com', 'bdawsonceo@gmail.com', text)
    

here are my errors: Traceback (most recent call last): File "c:\Users\hp\Desktop.py\Python Code Bank\networks, FCC YT\mailing client.py", line 15, in
server.login('bjdawsonxxxx@gmail.com', password) File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\smtplib.py", line 711, in login raise SMTPNotSupportedError( smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server. PS C:\Users\hp\Desktop.py\Python Code Bank\networks, FCC YT>

thanks in advance :)

DawsUTV
  • 35
  • 1
  • 2
  • 1
    Take a look at https://stackoverflow.com/questions/68472830/smtp-starttls-timeouterror-on-windows-10/68502962, possible you have to enable lower security in your gmail account – Yaroslav Kornachevskyi Aug 07 '21 at 22:11
  • Of the answers in the linked duplicate, [this one](https://stackoverflow.com/a/58997830/5320906) is probably the best. As Yaroslav notes, Google don't permit smtp connections to GMail without changes to your account's security configuration. And I believe that they require a secure connection, so you can't use port 25 (the answers to the duplicate use a secure connection). – snakecharmerb Aug 08 '21 at 07:53

0 Answers0