Inline Images in email are added a second time as attachments

A script that is correctly embedding inline images in HTML emails, is also adding the images as attachments. How can I eliminate this second copy of each image?

If any intended attachments are included, they’re processing correctly. With or without attachments, all images appear in the body of the message, and then again as an attachment. Removing the section for attachments (# Attach any files) makes no difference on the images. They still get included twice.

    import smtplib
    from email.message import EmailMessage
    from email import encoders
    from email.mime.base import MIMEBase
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText
    from email.mime.image import MIMEImage
    from import MIMEAudio
    import mimetypes
    strFrom = ''
    strPWord = 'XYZ'
    strTo = ''
    msg = EmailMessage()
    msg['Subject'] = 'This is a test at 1:22'
    msg['From'] = strFrom 
    msg['To'] = strTo 
    <!DOCTYPE html>
                <p><img src="cid:image1"/></p>
                 <p>Python email test</p>
                 <p><img src="cid:image2"/></p>
    ''', subtype='html')
    # Attach Any Images
    images = '''/Users/my/Desktop/RKw.jpeg\n/Users/my/Desktop/logo.png'''.splitlines()
    for image in images:
    	# print 'Image',i,': ',image,'\n'
    	fp = open(image, 'rb')
    	msgImage = MIMEImage(
    	# Define the image's ID as referenced above
    	msgImage.add_header('Content-ID', '<image'+str(i)+'>')
    # Attach any files
    files = ''''''.splitlines()
    for file in files:
    	ctype, encoding = mimetypes.guess_type(file)
    	if ctype is None or encoding is not None:
    		ctype = 'application/octet-stream'
    	maintype, subtype = ctype.split('/', 1)
    	with open(file, 'rb') as fp:
    						   filename=file.split('/')[-1].replace(' ','%20'))
    with smtplib.SMTP_SSL('', 465) as smtp:
        smtp.login(strFrom, strPWord) 

Are you sure that this is unexpected?
Surely the the image must be in the mime encoding for the HTML to refer to it.

Well, the images are inherently attached to the message; that’s how they
get sent with the message. Maybe your mailer treats them as attachments
regardless of why they’re attached?

But also read this:

Looks like you can set an “inline” Content-Disposition: header to
indicate that these are inline images, not to be treated like

Also, you should be able to group the HTML and the images in a multipart/related section: RFC 2387: The MIME Multipart/Related Content-type