问题
Hi I am using nodemailer to send email. My nodejs application is deployed on gcp instance with nginx reverse proxy. My code is able to send email locally but not from server. Note that ssl is also enabled.
note that this command is not running from telnet smtp.1and1.com 587
but this is running telnet smtp.gmail.com 587
This is my code
var transporterOptions = {
host: "smtp.1and1.com",
port: 587,
auth: {
user: email,
pass: pass
},
secure:true
};
回答1:
Google has blocked port 587 at the instance level, so you won't be able to send any email using that port. For more on information, visit Sending Email from an Instance which says:
Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.
However, there is a step by step guide for setiing up called Sending Email with SendGrid which you can follow.
来源:https://stackoverflow.com/questions/48995754/unable-to-send-email-from-nodemailer