refactor: project structure

This commit is contained in:
2023-10-21 20:31:31 +02:00
parent 1bbdbf751b
commit fc005a74c3
12 changed files with 215 additions and 104 deletions

View File

@@ -1,8 +1,8 @@
# Mail Sender
# Email Sender
## Description
`mail-sender` is a simple Go library designed to send emails with optional attachments. It's built on top of the standard Go `net/smtp` library with additional support for sending HTML emails and handling multiple attachments.
`email-sender` is a simple Go library designed to send emails with optional attachments. It's built on top of the standard Go `net/smtp` library with additional support for sending HTML emails and handling multiple attachments.
## Features
@@ -15,45 +15,13 @@
Clone this repository:
```
git clone https://gitea.urkob.com/urko/mail-sender.git
```bash
git clone https://gitea.urkob.com/urko/emailsender.git
```
## Usage
Here's a basic example on how to use the `mail-sender`:
1. **Initialize the Email Service**
```go
config := email.MailServiceConfig{
Auth: smtp.PlainAuth("", "your@email.com", "your-password", "smtp.youremail.com"),
Host: "smtp.youremail.com",
Port: "587",
From: "your@email.com",
}
mailService := email.NewMailService(config)
```
2. **Send an Email with an Attachment**
```go
emailData := email.EmailMessage{
To: "receiver@email.com",
Subject: "Test Email",
Body: "<h1>Hello!</h1><p>This is a test email.</p>",
Attachments: []email.EmailAttachment{
{
File: attachmentFile, // This is an io.Reader
Title: "document.pdf",
},
},
}
err := mailService.SendEmail(emailData)
if err != nil {
log.Fatal(err)
}
```
Check examples in [examples](https://gitea.urkob.com/urko/emailsender/examples)
## Dependencies