Skip to content

Commit c57d115

Browse files
committed
docs: add Mailgun setup instructions and configuration details
1 parent 9911a67 commit c57d115

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

adminforth/documentation/docs/tutorial/05-Plugins/07-email-password-reset.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,50 @@ Make sure to place your AWS credentials in `.env` file/environment.
6767
AWS_ACCESS_KEY_ID=your-access-key
6868
AWS_SECRET_ACCESS_KEY=your-secret-key
6969
```
70+
71+
72+
## Mailgun
73+
74+
To Setup Mailgun, you need to have an account and Mailgun service enabled. You can follow the steps below to setup Mailgun.
75+
76+
1. Go to [https://www.mailgun.com/](https://www.mailgun.com/) and create an account.
77+
2. Add your email address (any email), and verify it.
78+
3. Add your domain (any domain) and verify it.
79+
4. Add your API key.
80+
81+
Add plugin to user resource:
82+
83+
```typescript ./resources/adminuser.ts
84+
import EmailResetPasswordPlugin from '@adminforth/email-password-reset';
85+
import EmailAdapterMailgun from '@adminforth/email-adapter-mailgun';
86+
...
87+
plugins: [
88+
...
89+
new EmailResetPasswordPlugin({
90+
// field in user resource which contains email
91+
emailField: 'email',
92+
93+
// field in user resource which contains password constrains. Should be virtual field
94+
passwordField: 'password',
95+
96+
// domain part should be verified in Mailgun
97+
sendFrom: '[email protected]',
98+
99+
adapter: new EmailAdapterMailgun({
100+
apiKey: process.env.MAILGUN_API_KEY as string,
101+
domain: process.env.MAILGUN_DOMAIN as string,
102+
//baseUrl is optional, if not provided, will default to "https://api.mailgun.net" but if you are using Mailgun EU, you should use "https://api.eu.mailgun.net" instead
103+
baseUrl: process.env.MAILGUN_REGION_URL as string,
104+
}),
105+
106+
}),
107+
]
108+
```
109+
110+
Make sure to place your Mailgun credentials in `.env` file/environment.
111+
112+
```bash /.env
113+
MAILGUN_API_KEY=your-api-key
114+
MAILGUN_DOMAIN=your-domain
115+
MAILGUN_REGION_URL=your-region-url # optional
116+
```

0 commit comments

Comments
 (0)