in my NextJS project, the nodemailer is configured as a server component. it works fine locally but not after being deployed in AWS with Nginx.
The folder structure is src/app/api/mail/route.ts
I’m using the application-specific password from Gmail.
const transporter = nodemailer.createTransport({
service: 'gmail',
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASS
}
});
nginx config
server {
listen 80;
server_name MY PUBLIC_IP;
location /{
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Expecting to send email through the cloud as well as locally
New contributor
Kiru shanthan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.