I have this email program but it doestn seem to work, the emaik never arive at the reciever, not even in his spam folder

from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP

msg = MIMEMultipart()
msg['Subject'] = 'Email From Python jajaja'
msg['From'] = 'dairon@ceac.cu'
msg['Reply-to'] = 'otroemail@dominio'
msg['To'] = 'rms@gnu.org'

# That is what u see if dont have an email reader:
msg.preamble = 'Multipart massage.\n'

# This is the textual part:
part = MIMEText("Hello im sending an email from a python program")
msg.attach(part)

# This is the binary part(The Attachment):
part = MIMEApplication(open("TEST.txt","rb").read())
part.add_header('Content-Disposition', 'attachment', filename="TEST.txt")
msg.attach(part)

# Create an instance in SMTP server
smtp = SMTP("smtp.domain.cu")
# Start the server:
smtp.ehlo()
smtp.login("yo@example.com", "mipassword")

# Send the email
smtp.sendmail(msg['From'], msg['To'], msg.as_string())

So how do I send emails then? Can you send emails without having to create a SMTP server, if so how?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.