Python Forum
I get attachment paperclip on email without any attachments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I get attachment paperclip on email without any attachments
#1
Hi,

I'm trying to send a simple email with the code below:

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

def send_test_mail(body):
    sender_email = <SenderEmail>
    receiver_email = <ReceiverEmail>

    msg = MIMEMultipart()
    msg['Subject'] = '[Email Test]'
    msg['From'] = sender_email
    msg['To'] = receiver_email
    
    msgText = MIMEText('<b>%s</b>' % (body), 'html')
    msg.attach(msgText)

    try:
        with smtplib.SMTP_SSL('smtp.gmail.com', 587) as smtpObj:
            smtpObj.ehlo()
            smtpObj.login(<LoginUserName>, <LoginPassword>)
            smtpObj.sendmail(sender_email, receiver_email, msg.as_string())
    except Exception as e:
        print(e)
       
if __name__ == "__main__":
    send_test_mail("Welcome to Medium!")
Whe the email is received, I get the paperclip icon indicating there is an attachment when there clearly isn't one:

   

Python is not my strong point but I'm sure it has more to do with SMTPLIB rather than python.

Does anyone know what is going on here?

Thanks
Reply


Messages In This Thread
I get attachment paperclip on email without any attachments - by monika_v - Mar-16-2022, 09:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to download TLS Report attachment blason16 6 693 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  Extract PDF Attachment from Gmail jstaffon 0 639 Sep-10-2023, 01:55 PM
Last Post: jstaffon
  code to send attachments contained on the drive. stefanoste78 1 965 Oct-12-2022, 02:16 AM
Last Post: Larz60+
  Unable to send email attachments cosmarchy 7 2,786 Mar-09-2022, 09:29 PM
Last Post: bowlofred
  Trying to determine attachment file type before saving off.. cubangt 1 2,280 Feb-23-2022, 07:45 PM
Last Post: cubangt
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,202 Jan-07-2022, 07:38 PM
Last Post: cubangt
  Sending Attachments via smtplib [SOLVED] AlphaInc 3 2,268 Oct-28-2021, 12:39 PM
Last Post: AlphaInc
  Clicking Every Page and Attachment on Website shoulddt 1 1,809 Jul-09-2021, 01:08 PM
Last Post: snippsat
  ATT00001 instead of PDF attachment to an email dominiklucas 0 3,835 Jul-25-2020, 04:05 PM
Last Post: dominiklucas
  Sending an email with attachment without using SMTP? PythonNPC 5 3,342 May-05-2020, 07:58 AM
Last Post: PythonNPC

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020