1
1
import sharp from "sharp" ;
2
2
import { lexicalEditor } from "@payloadcms/richtext-lexical" ;
3
3
import { mongooseAdapter } from "@payloadcms/db-mongodb" ;
4
+ import { nodemailerAdapter } from "@payloadcms/email-nodemailer" ;
4
5
import { buildConfig , CollectionConfig , GlobalConfig } from "payload" ;
5
6
import path from "path" ;
6
7
import { fileURLToPath } from "url" ;
@@ -23,9 +24,27 @@ const csrf =
23
24
?. map ( ( d ) => d . trim ( ) )
24
25
?. filter ( Boolean ) ?? [ ] ;
25
26
27
+ let email = nodemailerAdapter ( ) ;
28
+ if ( process . env . SMTP_HOST && process . env . SMTP_PASS ) {
29
+ const smtpPort = Number ( process . env . SMTP_PORT ) || 587 ;
30
+ email = nodemailerAdapter ( {
31
+ defaultFromAddress :
32
+ process . env . SMTP_FROM_ADDRESS || "[email protected] " ,
33
+ defaultFromName : process . env . SENDGRID_FROM_NAME || "TrustLab CMS" ,
34
+ // Any Nodemailer transport can be used
35
+ transportOptions : {
36
+ host : process . env . SMTP_HOST ,
37
+ port : smtpPort ,
38
+ secure : smtpPort === 465 , // true for port 465, false (the default) for others
39
+ auth : {
40
+ user : process . env . SMTP_USER || "apikey" ,
41
+ pass : process . env . SMTP_PASS ,
42
+ } ,
43
+ } ,
44
+ } ) ;
45
+ }
46
+
26
47
export default buildConfig ( {
27
- serverURL : process . env . NEXT_PUBLIC_APP_URL ,
28
- editor : lexicalEditor ( ) ,
29
48
admin : {
30
49
importMap : {
31
50
baseDir : path . resolve ( dirname ) ,
@@ -34,6 +53,11 @@ export default buildConfig({
34
53
collections : [ Pages , Media , Users ] as CollectionConfig [ ] ,
35
54
cors,
36
55
csrf,
56
+ db : mongooseAdapter ( {
57
+ url : process . env . MONGO_URL || "" ,
58
+ } ) ,
59
+ email,
60
+ editor : lexicalEditor ( ) ,
37
61
globals : [ SiteSettings ] as GlobalConfig [ ] ,
38
62
...( locales ?. length
39
63
? {
@@ -44,14 +68,11 @@ export default buildConfig({
44
68
} ,
45
69
}
46
70
: undefined ) ,
71
+ plugins : [ ...plugins ] ,
47
72
secret : process . env . PAYLOAD_SECRET || "" ,
48
- db : mongooseAdapter ( {
49
- url : process . env . MONGO_URL || "" ,
50
- } ) ,
73
+ serverURL : process . env . NEXT_PUBLIC_APP_URL ,
74
+ sharp,
51
75
typescript : {
52
76
outputFile : path . resolve ( dirname , "payload-types.ts" ) ,
53
77
} ,
54
- plugins : [ ...plugins ] ,
55
-
56
- sharp,
57
78
} ) ;
0 commit comments