jothan / rustyknife

Fast, robust and safe email parsing library
GNU General Public License v3.0
19 stars 4 forks source link

Parsing AUTH commands #6

Open MikeAleksa opened 1 year ago

MikeAleksa commented 1 year ago

Is it possible to parse AUTH commands as well?

For example, sending mail to a local serving using the following command fails because SMTP AUTH extension not supported by server:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# SMTP server details
smtp_server = "localhost"
smtp_port = 8025

# Sender and recipient details
sender = "test@nothing.test"
recipient = "test@nothing.test"

# Create a message object
message = MIMEMultipart()
message["From"] = sender
message["To"] = recipient
message["Subject"] = "Test email"

# Add message content
message.attach(MIMEText("This is a test email.", "plain"))

# Connect to the SMTP server with TLS
smtp_obj = smtplib.SMTP(smtp_server, smtp_port)
smtp_obj.starttls()  # Enable TLS

# Send the email
smtp_obj.login(sender, "some_password") # <--- THIS LINE BREAKS THE SERVER
smtp_obj.sendmail(sender, recipient, message.as_string())

# Disconnect from the server
smtp_obj.quit()

print("Email sent successfully!")
Tsai002 commented 1 year ago

@MikeAleksa I have a awful version that support AUTH. https://github.com/jothan/smtpbis/commit/efdb1c62ef1fafe91575909d21fe7cd02972ceaa

MikeAleksa commented 1 year ago

Thanks @Tsai002 - was looking at implementing myself so that is a great starting point