Question

A use Mailgun to send b a email, after b receive the email and reply to a.If I want to track the email coming from b, How I can get the email? Here is the code:

1.sendmail.py

from smtplib import SMTP
import requests 

login_name = "postmaster@zzb.mailgun.org"
password   = "********"

def send_message_via_smtp():
smtp = SMTP("smtp.mailgun.org", 587)
smtp.login(login_name, password)
smtp.sendmail("zebozhuang@163.com","348284770@qq.com", "Subject:mailgun test \n\n just for test.\n\n") 
smtp.quit()



if __name__=="__main__":
send_message_via_smtp()

2.create_route.py

import requests
from werkzeug.datastructures import MultiDict

def create_route():
return requests.post(
        "https://api.mailgun.net/v2/routes",
        auth=("api", "key-9c4-t2q6fouilngjummvtv1rge7t00f2"),
        data=MultiDict([("priority", 1),
                    ("description", "Sample route"),
                    ("expression", "match_recipient('.*@qq.com')"),
                    ("action", "forward('qiyazhuang@gmail.com')"),
                    ("action", "stop()")])
    )

I create the route and I run the script sendmail.py.After someone who use email 348284770@qq.com reply to the other who use email zebozhuang@163.com, the Gmail can not receive the message by using the Mailgun method 'forward'. Could anyone tell me why?

Was it helpful?

Solution

Your messages are likely being delivered. Check the "Logs" tab of the Mailgun Control Panel.

Do you see any entries that look like this: Routed: .*@qq.com -> qiyazhuang@gmail.com 'SUBJECT HERE'

The "Routed" prefix means that the message triggered a Route. If you're seeing this, and the next log entry is prefixed with "Delivered", the message is likely being delivered to Gmail without issue. Check your Gmail spam folder if you still don't see the messages in the inbox folder.

Disclaimer: I work for Mailgun Support. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top