payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
21k stars 1.26k forks source link

Email Header issue #6895

Open AdvithShetty opened 6 days ago

AdvithShetty commented 6 days ago

Link to reproduction

No response

Payload Version

v3 beta.45

Node Version

v20.15.01

Next.js Version

14.2

Describe the Bug

I have tried using SMTP settings as displayed in the docs, also tried using the payload/email-nodemailer plugin and also sendmailer-sendgrid plugin

But even with defaultfromaddress provided the email sent do not have from address and the emails get rejected immediately.

I have even tried mailgun but that didn't work too but i got the error below:

`   5.7.1 [159.135.228.5] Gmail has detected that this message is not RFC 5322 5.7.1 compliant: 5.7.1 'From' header is missing. 5.7.1 To reduce the amount of spam sent to Gmail, this message has been 5.7.1 blocked. For more information, go to 5.7.1 https://support.google.com/mail/?p=RfcMessageNonCompliant and review 5.7.1 RFC 5322 specifications. 3f1490d57ef6-e02e65ef0f5si2637960276.635 - gsmtp  

`

Reproduction Steps

Done the setup according to the payload docs

Adapters and Plugins

sendmailer-sendgrid, email-nodemailer

qamarq commented 6 days ago

+1

bug desc: its making from header like: name <name> instead of correctone: name <email>

denolfe commented 4 days ago

@AdvithShetty Thanks for the report. Can you provide your email config?

AdvithShetty commented 4 days ago

I was using this previously

 email: nodemailerAdapter({
    // There is an issue with payload where FromName is being used for Name and Email
    // and therefore having to resort to using email in FromName and From Address
    defaultFromAddress:
      process.env.EMAIL_FROM_NAME ,
    defaultFromName:
      process.env.EMAIL_FROM_ADDRESS,
    transport: nodemailer.createTransport({
      // @ts-ignore
      host: process.env.SMTP_HOST,
      port: process.env.SMTP_PORT,
      // secure: true,
      auth: {
        user: process.env.SMTP_USER,
        pass:
          process.env.SMTP_PASS,
      },
    }),
  }),

now as a work around I have set both name and email as email

 email: nodemailerAdapter({
    // There is an issue with payload where FromName is being used for Name and Email
    // and therefore having to resort to using email in FromName and From Address
    defaultFromAddress:
      process.env.EMAIL_FROM_ADDRESS ,
    defaultFromName:
      process.env.EMAIL_FROM_ADDRESS,
    transport: nodemailer.createTransport({
      // @ts-ignore
      host: process.env.SMTP_HOST,
      port: process.env.SMTP_PORT,
      // secure: true,
      auth: {
        user: process.env.SMTP_USER,
        pass:
          process.env.SMTP_PASS,
      },
    }),
  }),