...
sender_pass = "pass" # password for SMTP server
sender_smtp = "
mail.com" # SMTP server
sender_port = 587 # SMTP port (here is SSL/TLS)
sender_user = "mymail" # STMP sender account
email_one= "
mail...@gmail.com"
email_two= "
emai...@gmail.com "
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Novi dnevni izvještaj"
msg['From'] = sender_user
#msg['To'] = email
msg['To'] = fiksni_email
msg['Cc'] = user_email
email_recipients_list=
email_one.split(",") +
email_two.split(",")
# e-mail text (plain)
mail_text = """Test
test
"""
# e-mail text (html)
mail_html = """\
<html>
<head></head>
<body>
<p>Test,<br><br>
Test
<hr>
<i style="font-size: 11px">Test</i>
</p>
</body>
</html>"""
with open(filename, 'rb') as f:
part = MIMEApplication(f.read(), Name=basename(filename))
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(mail_text, 'plain')
part2 = MIMEText(mail_html, 'html')
part['Content-Disposition'] = 'attachment; filename="{}"'.format(basename(filename))
# Attach parts into message container.
msg.attach(part1)
msg.attach(part2)
msg.attach(part)
# Send the message via local SMTP server.
s = smtplib.SMTP(sender_smtp, sender_port) # SMTP server params
#dbabic
s.starttls() # start SMTP session (TLS)
#dbabic
s.login(sender_user, sender_pass) # login to SMTP server
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(sender_user, email_recipients_list , msg.as_string())
s.quit()