5 months ago
I am trying their basic email format to send an email using a hobby plan. In the railway official blog, I saw this Outbound Networking article, which mentions "SMTP is only available on the Pro plan and above, while Free, Trial, and Hobby plans must use transactional email services with HTTPS APIs".
Email is working locally, but as soon as I deploy over the railway, I can't send an email using this.
Resend Example:
import resend
resend.api_key = "re_xxxxxxxxx"
params: resend.Emails.SendParams = {
"from": "Acme <onboarding@resend.dev>",
"to": ["delivered@resend.dev"],
"subject": "hello world",
"html": "<p>it works!</p>"
}
email = resend.Emails.send(params)
print(email)
16 Replies
5 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
5 months ago
Is there any error message in the log? It would be helpful if you could attach the log here
5 months ago
From your example, it might be because you didn't await the function, you might need to
`email = await resend.Emails.send(params)`
jer-tan
From your example, it might be because you didn't await the function, you might need to`email = await resend.Emails.send(params)`
5 months ago
here's the error log: https://prnt.sc/VDl7gw-lD8_J
Note: However everything is working fine while I'm running locally.
jer-tan
From your example, it might be because you didn't await the function, you might need to`email = await resend.Emails.send(params)`
5 months ago
how come? am not using async function also, if that's the case then i won't be able to use locally right?
raju-h
here's the error log: https://prnt.sc/VDl7gw-lD8_JNote: However everything is working fine while I'm running locally.
5 months ago
This looks like it’s your custom error handling message, just to make sure, you’re hardcoding the api key or you put it as environment variables? Perhaps you forgot to add your api key into environment variables on Railway
5 months ago
Kindly check if the API key on Resend if it’s still valid
jer-tan
This looks like it’s your custom error handling message, just to make sure, you’re hardcoding the api key or you put it as environment variables? Perhaps you forgot to add your api key into environment variables on Railway
5 months ago
I've set my API key in the environment variables, and here is my celery task that I'm using to send emails.
from celery import shared_task from django.conf import settings from django.template.loader import render_to_string import resend import logging logger = logging.getLogger("user_management") resend.api_key = settings.RESEND_API_KEY @shared_task def send_otp_email(email, otp, otp_for="account verification"): """Send OTP email asynchronously using Resend API""" subject = "Your OTP" html_message = render_to_string( "otp_email.html", { "otp": otp, "otp_for": otp_for, "expiry_minutes": settings.OTP_EXPIRY_TIME // 60, }, ) try: params = { "from": settings.DEFAULT_FROM_EMAIL, "to": [email], "subject": subject, "html": html_message, } response = resend.Emails.send(params) logger.info(f"OTP email sent to {email} via Resend API: {response}") return f"Email sent to {email}" except Exception as e: logger.error(f"Failed to send OTP email to {email} via Resend API: {str(e)}") return f"Failed to send email: {str(e)}"
jer-tan
Kindly check if the API key on Resend if it’s still valid
5 months ago
As I mentioned in the earlier comment, it's working locally without any issues.
5 months ago
Just to confirm, is the env ‘RESEND_API_KEY’ on Railway is setup?
5 months ago
I saw your host email is using ‘onboarding@resend.dev’ which is a test email, if you want to simulate successful email send, maybe try ‘delivered@resend.dev’
jer-tan
I saw your host email is using ‘onboarding@resend.dev’ which is a test email, if you want to simulate successful email send, maybe try ‘delivered@resend.dev’
5 months ago
let me try
4 months ago
Fwiw you should probably not be sharing screenshots of your API keys.
case
Fwiw you should probably not be sharing screenshots of your API keys.
4 months ago
Thank you, I already removed it.
4 months ago
Thanks, everyone. It's working now. After doing some research, I found that the issue wasn't in my code or the railway server.
Here's the resend error log:
You can only send testing emails to your own email address (the one associated with the email address I used to create the resend account). To send emails to other recipients, please verify a domain at resend.com/domains, and change the
fromaddress to an email using this domain.
I fixed it just by adding and verifying my domain on their platform.
Status changed to Solved brody • 4 months ago
