[Python] Error when submitting variables through Mailgun with Python

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to send mail through Mailgun with Python, in that instance I'm trying to push a variable alongside.

    My code is the following:

    requests.post("MailGun URL",
    auth=("api", "api-key"),
    data={
    "from":"From_Mail",
    "to":["To_Mail"],
    "template":"template_name",
    "subject":"Testing some things",
    "h:X-Mailgun-Variables": {"firstname": "John"}
    })


    If I use the above without "X-Mailgun-Variables" I'm not experiencing any problems, but with the above I get the following error message:

    "delivery-status": {
    "code": 621,
    "message": "",
    "attempt-no": 1,
    "description": "Failed to decode variables",
    "session-seconds": 0
    }


    What am I doing wrong?

    Thanks in advance,

    Continue reading...

Compartilhe esta Página