diff --git a/src/pages/email-server/how-tos/connect-via-platform/go.mdx b/src/pages/email-server/how-tos/connect-via-platform/go.mdx
index c9cb6914..fc2e2c05 100644
--- a/src/pages/email-server/how-tos/connect-via-platform/go.mdx
+++ b/src/pages/email-server/how-tos/connect-via-platform/go.mdx
@@ -66,40 +66,58 @@ MAIL_FROM=from@example.com`}
{`package main
-import(
+import (
"fmt"
- "strconv"
- "os"
- "github.com/go-gomail/gomail"
- "github.com/joho/godotenv"
+ "gopkg.in/gomail.v2"
+ "crypto/tls"
+ "os"
+ "strconv"
+ "github.com/joho/godotenv"
)
func main() {
+
+ // Load environment variables from .env file
err := godotenv.Load(".env")
if err != nil {
- fmt.Println(err)
+ fmt.Println("Error loading .env file:", err)
+ return
}
+ // Convert MAIL_PORT to int
mailPort, err := strconv.Atoi(os.Getenv("MAIL_PORT"))
if err != nil {
fmt.Println("Error converting MAIL_PORT to int:", err)
return
}
+
+ // Create a new email message
m := gomail.NewMessage()
- m.SetHeader("From", os.Getenv("MAIL_FROM"))
- m.SetHeader("To", "email@email.email")
+ m.SetHeader("From", os.Getenv("MAIL_FROM"))
+ m.SetHeader("To", "email@email.email") // Replace with actual recipient
m.SetHeader("Subject", "This is a TEST")
body := "this is really a test"
m.SetBody("text/plain", body)
+ // Create a new dialer
d := gomail.NewDialer(os.Getenv("MAIL_HOST"), mailPort, os.Getenv("MAIL_USERNAME"), os.Getenv("MAIL_PASSWORD"))
+ d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
- if err := d.DialAndSend(m); err != nil {
- fmt.Println("Error sending Test email:", err)
- }
-}`}
+ // Dial and send the email
+ if err := d.DialAndSend(m); err != nil {
+ fmt.Println("Error sending email:", err)
+ } else {
+ fmt.Println("Email sent successfully")
+ }
+}
+`}
+
+
+با تنظیم d.TLSConfig، میتوانید بهصورت امن اقدام به ارسال ایمیلهای تراکنشی کنید.
+
+
\ No newline at end of file
diff --git a/src/pages/email-server/how-tos/connect-via-platform/nextjs.mdx b/src/pages/email-server/how-tos/connect-via-platform/nextjs.mdx
index 0cd286cd..2f5d8c46 100644
--- a/src/pages/email-server/how-tos/connect-via-platform/nextjs.mdx
+++ b/src/pages/email-server/how-tos/connect-via-platform/nextjs.mdx
@@ -69,7 +69,7 @@ export default async function handler(req, res) {
const transporter = nodemailer.createTransport({
host: process.env.EMAIL_HOST,
port: 587,
- secure: false,
+ secure: true,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
@@ -97,6 +97,11 @@ export default async function handler(req, res) {
+با تنظیم secure: true، میتوانید بهصورت امن (tls) اقدام به ارسال ایمیلهای تراکنشی کنید.
+
+
+
+
فیلد from باید یکی از نشانیهای اضافه شده در سرویس ایمیل باشد.