package mail import ( "os" "testing" "github.com/joho/godotenv" ) func TestSendMailWithRealEnv(t *testing.T) { // Load the real .env file err := godotenv.Load() if err != nil { t.Skip("Skipping test: .env file not found") } // Check if SMTP configuration exists host := os.Getenv("SMTP_HOST") username := os.Getenv("SMTP_USERNAME") password := os.Getenv("SMTP_PASSWORD") if host == "" || username == "" || password == "" { t.Skip("Skipping test: SMTP configuration not found in .env") } // Create a real client using environment variables client := NewClient() // Test with a real email address (consider using a test address) recipients := []string{"romaric.sirii@gmail.com"} subject := "Test Email from Go Test" body := "This is a test email sent from the mail package test" // Send the email err = client.SendMail(recipients, subject, body) if err != nil { t.Errorf("SendMail failed with error: %v", err) } }