# Email and Templates

### All templates path

<pre><code>├── node_modules
<strong>├── mail-templates
</strong>│   ├── account-created.pug            # When account is created
│   ├── failed-payment.pug             # When a subscription renew failed
│   ├── reset-password.pug             # When user request lost password
│   ├── success-payment.pug            # When a payment is successfully
<strong>│   ├── updated-subscription.pug       # When user change subscription       
</strong></code></pre>

### Set up Email environment variables in <mark style="color:blue;">.env</mark>

```
# MAILING
SMTP_HOST=
SMTP_PORT=
SMTP_SECURE=false
SMTP_AUTH=
SMTP_PASSWORD=
SMTP_FROM='"Support name" <support@domain.name>'
MODERATION_MAIL=
```

### How To send a email?

```typescript
// import user service
import { UsersService } from 'src/domains/users/users.service';
constructor(private readonly usersService: UsersService) {}

// call send email to user
await this.usersService.sendMailToUser(...)
```
