I
I
IvankoPo2017-07-12 18:31:30
Python
IvankoPo, 2017-07-12 18:31:30

How to send/attach a picture?

There is a script in python 3, you need to send a text message everything is fine, but you still need to attach a photo how to do it? I tried using html markup to insert an image, it did not work.
My code at the moment

import smtplib
email = smtplib.SMTP('smtp.gmail.com', 587)
message = """From: <[email protected]>
To: Ivan
Content-type: text/html
Subject: SMTP e-mail test

This is a test e-mail message.
<h1>Hello</h1>
<b> Its ivan </b>
<img src="/Users/ivan/PycharmProjects/mail/user.jpg">
"""
email.starttls()
email.login('[email protected]', '********')
email.sendmail("[email protected]", "[email protected]", message)
email.quit()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-05-28
@Survtur

To insert an image into HTML, rather than attach something to a letter, you can use https://ru.wikipedia.org/wiki/Data:_URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question