Sending Actual Mail with Mailtrap

990 views Asked by At

Please how do one send actual mail with Mailtrap? Seems all mail stay at the inbox without actually hitting the recipient.

3

There are 3 answers

0
Chris Clark On BEST ANSWER

Mailtrap is a fake SMTP server for development teams to test, view and share emails sent from the development and staging environments. It won’t hit a real recipient. Take a look at SendGrid for sending real email.

0
Viktoriia On

Basically, if you're using Mailtrap Email Testing, you cannot send them to the recipients because this solution only helps to test emails on staging. Mailtrap has two products, and if you need to send emails, you should use Email Sending specifically, and there is a real SMTP for the sending purposes.

0
Mac On

See the mailtrap.io FAQ here. If you've already have your domain and everything already set up, your code should look like this (Python 2.7+)

import requests


url = "https://send.api.mailtrap.io/api/send"

payload = "{\"from\":{\"email\":\"mailtrap@<enter your domain here>.com\"," \
          "\"name\":\"Mailtrap Email\"}," \
          "\"to\":[{\"email\":\"<enter the target email address here>\"}]," \
          "\"subject\":\"You are awesome!\"," \
          "\"text\":\"Congrats for sending email with Mailtrap!\"," \
          "\"category\":\"Integration Test\"}"
headers = {
  "Authorization": "<your auth code>",
  "Content-Type": "application/json"
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

If you get a 200 (success) response, then you should be good to go.