Compare commits
No commits in common. "bbf75783e7c8b106c75fef76641f28214be05012" and "42644cc0c89dd35c7b3fb75da416fbc76c572edb" have entirely different histories.
bbf75783e7
...
42644cc0c8
65
README.md
65
README.md
|
@ -1,65 +0,0 @@
|
||||||
# Mail 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.
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- Send HTML emails.
|
|
||||||
- Attach multiple files to the email.
|
|
||||||
- Built-in support for TLS encryption.
|
|
||||||
- Simple API for sending emails.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Clone this repository:
|
|
||||||
|
|
||||||
```
|
|
||||||
git clone https://gitea.urkob.com/urko/mail-sender.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)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
- Go's standard `net/smtp` package
|
|
||||||
- Go's standard `crypto/tls` package for secure email sending.
|
|
||||||
|
|
||||||
## Contribution
|
|
||||||
|
|
||||||
Feel free to submit issues or pull requests if you find any bugs or have suggestions for improvements.
|
|
Loading…
Reference in New Issue