Crates.io | smtp2go |
lib.rs | smtp2go |
version | 0.1.6 |
source | src |
created_at | 2017-02-19 21:59:42.41266 |
updated_at | 2021-03-18 23:35:44.124332 |
description | SMTP2GO api interface for email sending |
homepage | |
repository | https://github.com/smtp2go-oss/smtp2go-rust |
max_upload_size | |
id | 8591 |
size | 10,107 |
Rust wrapper around the SMTP2GO /email/send API endpoint.
Add this line to your Cargo.toml in the [dependencies] block
smtp2go = "0.1.6"
Sign up for a free account here and once logged in navigate
to the Settings -> Api Keys
page, create a new API key and make sure the /email/send
endpoint
is enabled:
Once you have an API key you need to export it into the environment where your Rust application is going to be executed, this can be done on the terminal like so:
`$ export SMTP2GO_API_KEY="<your_API_key>"`
Or alternatively you can set it in code using the std::env::set_var
function.
Then sending mail is as simple as:
match smtp2go::Email::new()
.from("Matt <matt@example.com>")
.to(&[
"Dave <dave@example.com>".to_string()
])
.subject("Trying out SMTP2Go")
.text_body("Test message")
.send().await {
Ok(response) => println!("Message Successfully Sent - {:?}", response),
Err(error) => println!("Message failed: Error: {:?}", error)
};
Clone repo. Run tests with cargo test
.
Bug reports and pull requests are welcome on GitHub here
The package is available as open source under the terms of the MIT License.