Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(email_message): encapsulate EmailMessage and Attachment struct with private fields and add constructors #16

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .examples/.serverless/aws_lambda/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/darkrockmountain/gomail/aws_lambda_email_sender

go 1.22.1
go 1.22.4

require (
github.com/aws/aws-lambda-go v1.47.0
Expand Down
2 changes: 1 addition & 1 deletion .examples/.serverless/azure_functions/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/darkrockmountain/gomail/azure_email_sender

go 1.22.1
go 1.22.4

require github.com/darkrockmountain/gomail v0.5.1
2 changes: 1 addition & 1 deletion .examples/.serverless/google_cloud_functions/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/darkrockmountain/gomail/google_cloud_email_sender

go 1.22.1
go 1.22.4

require (
github.com/GoogleCloudPlatform/functions-framework-go v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.3
go-version: 1.22.4

- name: Install dependencies
run: go mod tidy
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.3
go-version: 1.22.4

- name: Run tests and generate coverage
run: go test -coverprofile=coverage.out ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govulncheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
- id: govulncheck
uses: golang/govulncheck-action@3a32958c2706f7048305d5a2e53633d7e37e97d0 # v1.0.2
with:
go-version-input: 1.22.3
go-version-input: 1.22.4
go-package: ./...
4 changes: 1 addition & 3 deletions docs/AWS_SES_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ if err != nil {
// Define email message
message := gomail.NewEmailMessage(sender,[]string{"recipient@example.com"}, "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,
})
AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))



Expand Down
4 changes: 1 addition & 3 deletions docs/Gmail_Credentials_API_Key.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ if err != nil {

// Define email message using an alias email address
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))



Expand Down
4 changes: 1 addition & 3 deletions docs/Gmail_Credentials_JWT.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ if err != nil {

// Define email message using an alias email address
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Gmail_Credentials_OAuth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ if err != nil {

// Define email message using an alias email address
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Gmail_Credentials_ServiceAccount copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ if err != nil {

// Define email message using an alias email address
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Gmail_Credentials_ServiceAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ if err != nil {

// Define email message using an alias email address
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Mailgun_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Mandrill_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Microsoft365_Credentials_ROPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Microsoft365_Credentials_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Microsoft365_Credentials_credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Microsoft365_Credentials_managed_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Microsoft365_Credentials_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/Postmark_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/SMTP_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

// Send email
if err := emailSender.SendEmail(message); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions docs/SendGrid_Credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ if err != nil {

// Define email message
message := gomail.NewEmailMessage("your-email_or_alias@example.com",[]string{"recipient@example.com"}, "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,
})
SetHTML("<p>This is the <b>HTML</b> part of the <i>email</i>.</p>").AddAttachments(*gomail.NewAttachment("attachment.jpg", attachmentContent))

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