yagmail tries to "guess" MIME type for attachments using filename extension. However, urllib.urlretrieve writes retrieved content to a temporary file with no extension, so yagmail is unable to determine that attachment is an image and use the correct content-type. By using an explicit destination filename with a ".jpg" extension, yagmail will use Content-type: image/jpeg for the MIME object and, hopefully, email clients will handle appropriately [#18].
Also, by using the yagmail inline type, image will be embedded in the body of the email's HTML part rather that as an attachment (on yagmail>=0.5.156) [#5]. Note that this may be undesirable to some--if they prefer it as a true attachment, rather than inline. Might be better to have this as a configuration option?
Should fix #5 and fix #18
yagmail tries to "guess" MIME type for attachments using filename extension. However, urllib.urlretrieve writes retrieved content to a temporary file with no extension, so yagmail is unable to determine that attachment is an image and use the correct content-type. By using an explicit destination filename with a ".jpg" extension, yagmail will use Content-type: image/jpeg for the MIME object and, hopefully, email clients will handle appropriately [#18].
Also, by using the yagmail inline type, image will be embedded in the body of the email's HTML part rather that as an attachment (on
yagmail>=0.5.156
) [#5]. Note that this may be undesirable to some--if they prefer it as a true attachment, rather than inline. Might be better to have this as a configuration option?