https://github.com/jacraig/simplemail
SimpleMail is a C# library designed to simplify sending emails. It provides a convenient and straightforward interface for sending email messages.
https://github.com/jacraig/simplemail
email-sender mailkit
Last synced: 10 months ago
JSON representation
SimpleMail is a C# library designed to simplify sending emails. It provides a convenient and straightforward interface for sending email messages.
- Host: GitHub
- URL: https://github.com/jacraig/simplemail
- Owner: JaCraig
- License: apache-2.0
- Created: 2016-11-22T17:15:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T01:45:09.000Z (about 2 years ago)
- Last Synced: 2024-04-09T02:42:36.109Z (about 2 years ago)
- Topics: email-sender, mailkit
- Language: C#
- Homepage: https://jacraig.github.io/SimpleMail/
- Size: 17.6 MB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# SimpleMail
[](https://github.com/JaCraig/SimpleMail/actions/workflows/dotnet-publish.yml)
SimpleMail is a C# library designed to simplify sending emails. It provides a convenient and straightforward interface for sending email messages.
## Features
- Easy-to-use API for sending emails and attachments
- Compatible with .NET 8 and above
## Installation
SimpleMail can be easily installed via NuGet:
```
dotnet add package SimpleMail
```
Alternatively, you can search for "SimpleMail" in the NuGet Package Manager UI and install it from there.
## Getting Started
To use SimpleMail in your project, follow these simple steps:
1. Add a reference to the SimpleMail namespace in your code file:
```csharp
using SimpleMail;
```
2. Create an instance of the `EmailMessage` class:
```csharp
// Create a new email
Email email = new Email
{
// Email address to send the email from
From = "system@example.com",
// Email address to send the email to
To = ["someone@example.com"],
// Subject of the email
Subject = "Example Subject",
// Body of the email
Body = "Example Body",
// Password of the email account
Password = "password",
// Email server to send the email
Server = "smtp.example.com",
// Username of the email account
UserName = "username",
// Port of the email server (default is 25)
Port = 587,
// Use SSL to encrypt the connection
UseSSL = true,
// Priority of the email
Priority = MimeKit.MessagePriority.Urgent,
// Reply-to address
ReplyTo = ["replyto@example.com"]
};
```
Or if you want to supply your own SmtpClient, you can do so. This is useful if you want to use a custom SmtpClient with specific settings:
```csharp
// Create a new email
Email email = new Email(new SmtpClient())
{
// Email address to send the email from
From = "system@example.com",
...
};
```
Note that the SmtpClient instance is not disposed of by SimpleMail, so you will need to dispose of it yourself when you are done with it.
3. Send the email:
```csharp
await email.SendAsync().ConfigureAwait(false);
```
That's it! You have successfully sent an email using SimpleMail.
## Compatibility
SimpleMail is compatible with .NET 8 and above.
## Contributing
We welcome contributions to SimpleMail! If you encounter any issues, have suggestions for improvements, or would like to contribute new features, please feel free to submit a pull request.
## License
SimpleMail is released under the [Apache 2 License](https://github.com/JaCraig/SimpleMail/blob/master/LICENSE).