Already registered? Log in
Instructions for setting up a Go wrapper around the SMTP2GO /email/send
API endpoint.
To install:</>
go get github.com/smtp2go-oss/smtp2go-go
Add the import in your source file:>
import "github.com/smtp2go-oss/smtp2go-go"
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=""
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 ")
.to(&[
"Dave ".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.