diff options
author | 2024-02-11 19:15:20 +0530 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 8fec21d6bccfa778c14c1714d6444312e36fc3f1 (patch) | |
tree | cab910ad5048eece2d229648f2c17000ac86a44d /config/mail.ts | |
parent | updates (diff) | |
download | ferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.tar.gz ferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.tar.zst ferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.zip |
Diffstat (limited to 'config/mail.ts')
-rw-r--r-- | config/mail.ts | 111 |
1 files changed, 24 insertions, 87 deletions
diff --git a/config/mail.ts b/config/mail.ts index ac67231..dbe4bdf 100644 --- a/config/mail.ts +++ b/config/mail.ts | |||
@@ -1,118 +1,55 @@ | |||
1 | /** | ||
2 | * Config source: https://git.io/JvgAf | ||
3 | * | ||
4 | * Feel free to let us know via PR, if you find something broken in this contract | ||
5 | * file. | ||
6 | */ | ||
7 | |||
8 | import env from '#start/env'; | 1 | import env from '#start/env'; |
9 | import { defineConfig } from '@adonisjs/mail'; | 2 | import { defineConfig, transports } from '@adonisjs/mail'; |
10 | 3 | ||
11 | export default defineConfig({ | 4 | const mailConfig = defineConfig({ |
12 | /* | 5 | default: 'smtp', |
13 | |-------------------------------------------------------------------------- | ||
14 | | Default mailer | ||
15 | |-------------------------------------------------------------------------- | ||
16 | | | ||
17 | | The following mailer will be used to send emails, when you don't specify | ||
18 | | a mailer | ||
19 | | | ||
20 | */ | ||
21 | mailer: env.get('MAIL_CONNECTION', 'smtp'), | ||
22 | 6 | ||
23 | /* | 7 | /** |
24 | |-------------------------------------------------------------------------- | 8 | * The mailers object can be used to configure multiple mailers |
25 | | Mailers | 9 | * each using a different transport or same transport with different |
26 | |-------------------------------------------------------------------------- | 10 | * options. |
27 | | | 11 | */ |
28 | | You can define or more mailers to send emails from your application. A | ||
29 | | single `driver` can be used to define multiple mailers with different | ||
30 | | config. | ||
31 | | | ||
32 | | For example: Postmark driver can be used to have different mailers for | ||
33 | | sending transactional and promotional emails | ||
34 | | | ||
35 | */ | ||
36 | mailers: { | 12 | mailers: { |
37 | /* | 13 | smtp: transports.smtp({ |
38 | |-------------------------------------------------------------------------- | ||
39 | | Smtp | ||
40 | |-------------------------------------------------------------------------- | ||
41 | | | ||
42 | | Uses SMTP protocol for sending email | ||
43 | | | ||
44 | */ | ||
45 | smtp: drivers.smtp({ | ||
46 | name: env.get('APP_URL'), | ||
47 | port: env.get('SMTP_PORT', '2525'), | 14 | port: env.get('SMTP_PORT', '2525'), |
48 | host: env.get('SMTP_HOST', 'localhost'), | 15 | host: env.get('SMTP_HOST', 'localhost'), |
49 | secure: JSON.parse(env.get('MAIL_SSL', 'false')), | 16 | secure: JSON.parse(env.get('MAIL_SSL', 'false')), |
50 | requireTLS: JSON.parse(env.get('MAIL_REQUIRE_TLS', 'false')), | 17 | requireTLS: JSON.parse(env.get('MAIL_REQUIRE_TLS', 'false')), |
51 | auth: { | 18 | auth: { |
52 | user: env.get('MAIL_USERNAME'), | 19 | user: env.get('MAIL_USERNAME')!, |
53 | pass: env.get('MAIL_PASSWORD'), | 20 | pass: env.get('MAIL_PASSWORD')!, |
54 | type: 'login', | 21 | type: 'login', |
55 | }, | 22 | }, |
56 | maxConnections: 5, | 23 | maxConnections: 5, |
57 | maxMessages: 100, | 24 | maxMessages: 100, |
58 | rateLimit: 10, | ||
59 | }), | 25 | }), |
60 | 26 | ||
61 | /* | 27 | ses: transports.ses({ |
62 | |-------------------------------------------------------------------------- | ||
63 | | SES | ||
64 | |-------------------------------------------------------------------------- | ||
65 | | | ||
66 | | Uses Amazon SES for sending emails. You will have to install the aws-sdk | ||
67 | | when using this driver. | ||
68 | | | ||
69 | | ``` | ||
70 | | npm i aws-sdk | ||
71 | | ``` | ||
72 | | | ||
73 | */ | ||
74 | ses: drivers.ses({ | ||
75 | apiVersion: '2010-12-01', | 28 | apiVersion: '2010-12-01', |
76 | key: env.get('SES_ACCESS_KEY'), | 29 | credentials: { |
77 | secret: env.get('SES_ACCESS_SECRET'), | 30 | accessKeyId: env.get('SES_ACCESS_KEY')!, |
78 | region: env.get('SES_REGION'), | 31 | secretAccessKey: env.get('SES_ACCESS_SECRET')!, |
79 | sslEnabled: true, | 32 | }, |
33 | region: process.env.SES_REGION!, | ||
80 | sendingRate: 10, | 34 | sendingRate: 10, |
81 | maxConnections: 5, | 35 | maxConnections: 5, |
82 | }), | 36 | }), |
83 | 37 | ||
84 | /* | 38 | mailgun: transports.mailgun({ |
85 | |-------------------------------------------------------------------------- | ||
86 | | Mailgun | ||
87 | |-------------------------------------------------------------------------- | ||
88 | | | ||
89 | | Uses Mailgun service for sending emails. | ||
90 | | | ||
91 | | If you are using an EU domain. Ensure to change the baseUrl to hit the | ||
92 | | europe endpoint (https://api.eu.mailgun.net/v3). | ||
93 | | | ||
94 | */ | ||
95 | mailgun: drivers.mailgun({ | ||
96 | baseUrl: 'https://api.mailgun.net/v3', | 39 | baseUrl: 'https://api.mailgun.net/v3', |
97 | key: env.get('MAILGUN_API_KEY'), | 40 | key: env.get('MAILGUN_API_KEY')!, |
98 | domain: env.get('MAILGUN_DOMAIN'), | 41 | domain: env.get('MAILGUN_DOMAIN')!, |
99 | }), | 42 | }), |
100 | 43 | ||
101 | /* | 44 | sparkpost: transports.sparkpost({ |
102 | |-------------------------------------------------------------------------- | ||
103 | | SparkPost | ||
104 | |-------------------------------------------------------------------------- | ||
105 | | | ||
106 | | Uses Sparkpost service for sending emails. | ||
107 | | | ||
108 | */ | ||
109 | sparkpost: drivers.sparkpost({ | ||
110 | baseUrl: 'https://api.sparkpost.com/api/v1', | 45 | baseUrl: 'https://api.sparkpost.com/api/v1', |
111 | key: env.get('SPARKPOST_API_KEY'), | 46 | key: env.get('SPARKPOST_API_KEY')!, |
112 | }), | 47 | }), |
113 | }, | 48 | }, |
114 | }); | 49 | }); |
115 | 50 | ||
51 | export default mailConfig; | ||
52 | |||
116 | declare module '@adonisjs/mail/types' { | 53 | declare module '@adonisjs/mail/types' { |
117 | export interface MailersList extends InferMailers<typeof mailConfig> {} | 54 | export interface MailersList extends InferMailers<typeof mailConfig> {} |
118 | } | 55 | } |