0

I've written code which creates a csv file that is later sent by SendGrid. The code works with gmail. The message shows up in the inbox in an instant, but does not on other clients like CyberFolks. The response status is 202. You can find the part responsible for sending the email below -

 SG_apikey = sendgrid_api
    from_email = Email("my@mail.com")
    to_email = To("my_friends@mail.com")
    cc_mail = Cc("my_gmail@gmail.com")
    subject = f"Orders from XXX for"
    content = Content("text/plain", "Orders from XXX for can be found in attachment")

    with open("orders.csv", "rb") as f:
        base = base64.b64encode(f.read()).decode()

    attachment = Attachment(
        file_content=FileContent(base),
        file_name=FileName("orders.csv"),
        file_type=FileType("text/csv"),
        disposition=Disposition("attachment"),
    )

    mail = Mail(from_email, to_email, subject, content)
    mail.add_attachment(attachment)
    mail.add_cc(cc_mail)
    sendgrid_client = SendGridAPIClient(api_key=SG_apikey)
    response = sendgrid_client.send(mail.get())
    print(response.status_code)
    print(response.headers)

Do you have any ideas for solving this problem?

I have tried :

  1. Changing the MIME TYPES

  2. Checking if the mail address is misspelled

  3. The SendGrid panel. My domain is authorized/validated. But to be sure I have checked/done it more than once.

  4. Sending the email with and without an attachment.

Nob0Dy
  • 54
  • 6
Janek
  • 1
  • 2
  • Are you sending literally from `@mail.com`? If so, that mail is going in the trash. – tadman May 10 '23 at 15:48
  • nope i am using valid adress , I've changes to fake one on purpose to stay anonymous – Janek May 10 '23 at 16:22
  • Seems like you have the same problem that is discussed [in this question](https://stackoverflow.com/questions/42214048/sendgrid-returns-202-but-doesnt-send-email?rq=2) – IObert May 11 '23 at 10:33

0 Answers0