MyGit

v3.0.0-beta.12

payloadcms/payload

版本发布时间: 2024-04-23 23:29:14

payloadcms/payload最新发布版本:v3.0.2(2024-11-21 05:11:39)

v3.0.0-beta.12

Features

Fixes

⚠ BREAKING CHANGES

Providing an email configuration is now optional. If using nodemailer before, you will need to install a new package @payloadcms/email-nodemailer and use it in your config.

Email Configuration Before:

// via payload.init
payload.init({
  email: {
    transport: someNodemailerTransport
    fromName: 'hello',
    fromAddress: 'hello@example.com',
  },
})
// or via email in payload.config.ts
export default buildConfig({
  email: {
    transport: someNodemailerTransport
    fromName: 'hello',
    fromAddress: 'hello@example.com',
  },
})

Email Configuration After:

// Using new nodemailer adapter package

import { nodemailerAdapter } from '@payloadcms/email-nodemailer'

export default buildConfig({
  email: nodemailerAdapter() // This will be the old ethereal.email functionality
})

// or pass in transport

export default buildConfig({
  email: nodemailerAdapter({
    defaultFromAddress: 'info@payloadcms.com',
    defaultFromName: 'Payload',
    transport: await nodemailer.createTransport({
      host: process.env.SMTP_HOST,
      port: 587,
      auth: {
        user: process.env.SMTP_USER,
        pass: process.env.SMTP_PASS,
      },
    })
  })
})
// Create custom email adapter

// myAdapter.ts
import type { EmailAdapter, SendMailOptions } from 'payload/types'

export const myAdapter: EmailAdapter = ({ payload }) => ({
  defaultFromAddress: defaults.defaultFromAddress,
  defaultFromName: defaults.defaultFromName,
  sendEmail: async (message) => {
    // Perform any logic here
    console.log(`To: '${message.to}', Subject: '${message.subject}'`)
    return Promise.resolve()
  },
})

// payload.config.ts
export default buildConfig({
  email: myAdapter()
})

相关地址:原始地址 下载(tar) 下载(zip)

查看:2024-04-23发行的版本