Skip to content

Commit

Permalink
Merge pull request #10 from DarkRockMountain/feature/encapsulate-emai…
Browse files Browse the repository at this point in the history
…l-message

refactor(email_sender): encapsulate EmailMessage struct
  • Loading branch information
DarkRockMountain-admin authored Jun 4, 2024
2 parents 90ac9ee + 96ab8e7 commit 9052992
Show file tree
Hide file tree
Showing 30 changed files with 799 additions and 646 deletions.
15 changes: 7 additions & 8 deletions docs/AWS_SES_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: sender,
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage(sender,[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").
AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})



// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
14 changes: 6 additions & 8 deletions docs/Gmail_Credentials_API_Key.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ if err != nil {
}

// Define email message using an alias email address
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with Alias",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})



// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Gmail_Credentials_JWT.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ if err != nil {
}

// Define email message using an alias email address
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with Alias",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Gmail_Credentials_OAuth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,10 @@ if err != nil {
}

// Define email message using an alias email address
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with Alias",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Gmail_Credentials_ServiceAccount copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,10 @@ if err != nil {
}

// Define email message using an alias email address
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with Alias",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Gmail_Credentials_ServiceAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,10 @@ if err != nil {
}

// Define email message using an alias email address
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with Alias",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Mailgun_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Mandrill_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Microsoft365_Credentials_ROPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Microsoft365_Credentials_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Microsoft365_Credentials_credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Microsoft365_Credentials_managed_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Microsoft365_Credentials_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/Postmark_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/SMTP_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions docs/SendGrid_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ if err != nil {
}

// Define email message
message := gomail.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Test Email with attachment",
Text: "This is the plain text part of the email.",
HTML: "<p>This is the <b>HTML</b> part of the <i>email</i>.</p>",
Attachments: []gomail.Attachment{{Filename: "attachment.jpg", Content: attachmentContent}},
}
message := *gomail.NewEmailMessage("[email protected]",[]string{"[email protected]"}, "Test Email with attachment", "This is the plain text part of the email.").
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(gomail.Attachment{
Filename: "attachment.jpg", Content: attachmentContent,
})

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
Loading

0 comments on commit 9052992

Please sign in to comment.