Skip to content

Commit bcd8d0c

Browse files
committed
tweak: clarify Nodemailer section in email testing documentation
- Clarified that the Nodemailer example is for testing MailHog setup\n- Added information about how Puter uses Nodemailer\n- Added references to the EmailService class ai: true
1 parent 71fd941 commit bcd8d0c

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

doc/contributors/email_testing.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,50 @@ Once MailHog is running, access the web interface at:
4343

4444
All captured emails and their recipients will be displayed in this interface.
4545

46-
### Sending Test Emails with Nodemailer
46+
### Testing Your MailHog Setup with Nodemailer
4747

48-
Use Nodemailer as the transport method to send emails via SMTP. These emails will be captured by MailHog:
48+
You can verify that your MailHog instance is working correctly by creating a simple test script using Nodemailer. This allows you to send test emails that will be captured by MailHog without actually delivering them to real recipients.
49+
50+
Here's a sample script you can use to test your MailHog setup:
4951

5052
```javascript
5153
import nodemailer from "nodemailer";
5254

55+
// Configure transporter to use MailHog
5356
const transporter = nodemailer.createTransport({
54-
host: "localhost", // SMTP server (MailHog in this case)
57+
host: "localhost", // MailHog SMTP server address
5558
port: 1025, // Default MailHog SMTP port
56-
secure: false // No SSL/TLS required
59+
secure: false // No SSL/TLS required for MailHog
5760
});
5861

62+
// Define a test email
5963
const mailOptions = {
6064
6165
6266
subject: "Hello from Nodemailer!",
6367
text: "This is a test email sent using Nodemailer."
6468
};
6569

70+
// Send the test email
6671
transporter.sendMail(mailOptions)
6772
.then(info => console.log("Email sent:", info.response))
6873
.catch(error => console.error("Error:", error));
6974
```
7075

71-
After sending an email, you can view it in the MailHog web interface:
76+
After sending an email with this script, you can view it in the MailHog web interface:
77+
78+
### How Puter Uses Nodemailer
79+
80+
Puter itself uses Nodemailer for sending emails through its `EmailService` class located in `/src/backend/src/services/EmailService.js`. This service handles various email templates for:
81+
82+
- Account verification
83+
- Password recovery
84+
- Two-factor authentication notifications
85+
- File sharing notifications
86+
- App approval notifications
87+
- And more
88+
89+
The service creates a Nodemailer transport using the configuration from your `config.json` file, which is why setting up MailHog correctly is important for testing Puter's email functionality during development.
7290

7391
<img src="image.png" alt="Email in MailHog interface" width="300" height="200">
7492

0 commit comments

Comments
 (0)