7 releases

0.1.6 Mar 18, 2021
0.1.5 Mar 18, 2021
0.1.4 Feb 22, 2017

#128 in Email

Download history 119/week @ 2024-02-12 21/week @ 2024-02-19 4/week @ 2024-02-26

144 downloads per month

MIT license

8KB
152 lines

Crates.io Build Status license

SMTP2GO API

Rust wrapper around the SMTP2GO /email/send API endpoint.

Installation

Add this line to your Cargo.toml in the [dependencies] block

smtp2go = "0.1.6"

Usage

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)
		};

Development

Clone repo. Run tests with cargo test.

Contributing

Bug reports and pull requests are welcome on GitHub here

License

The package is available as open source under the terms of the MIT License.

Dependencies

~9–24MB
~353K SLoC