#SMTP email / gmail

3 messages · Page 1 of 1 (latest)

royal phoenix
#

I'm trying to send emails using gmail smtp, I already create a pass for my smtp account (setting 2step verification and pass). Do I need to do something else? 😅

This is my config

payload.init({
  secret: process.env.PAYLOAD_SECRET,
  mongoURL: process.env.MONGODB_URI,
  express: app,
  onInit: () => {
    payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
  },
  email: {
    transportOptions: {
      host: process.env.SMTP_HOST,
      auth: {
        user: process.env.SMTP_USER,
        pass: process.env.SMTP_PASS,
      },
      port: 587,
      secure: true, // use TLS
      tls: {
        // do not fail on invalid certs
        rejectUnauthorized: false,
      },
    },
    fromName: 'hello',
    fromAddress: process.env.SMTP_FROM,
  },
});

I'm getting this errors:

There is an error with the email configuration you have provided. Error: 4041A9DD01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:
elder spade
#

add service gmail, set secure to false and remove tls transportOptions: { service: "gmail", host: process.env.SMTP_HOST, auth: { user: process.env.SMTP_USER, pass: process.env.EMAIL_APP_PASS, }, port: 587, secure: false, },

terse cove
#

Google requires SSL on email going out of gmail:

If you connect using SSL or TLS, you can send email to anyone inside or outside of your organization using smtp.gmail.com as your SMTP server. This option requires you to authenticate with your Gmail or Google Workspace account and passwords