Already registered? Log in
Add this line to your Cargo.toml in the [dependencies] block:
smtp2go = "0.1.6"
Log in to your SMTP2GO account and navigate to:
Settings -> Api Keys
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)
};
Try SMTP2GO free for as long as you like:
Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.