Lettre site https://lettre.github.io/lettre/ Recent content on Lettre site Hugo -- gohugo.io en-us Sun, 21 May 2017 23:46:17 +0200 Introduction https://lettre.github.io/lettre/getting-started/intro/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/getting-started/intro/ Lettre is an email library that allows creating and sending messages. It provides: An easy to use email builder Pluggable email transports Unicode support (for emails and transports, including for sender et recipient addresses when compatible) Secure defaults (emails are only sent encrypted by default) Introduction https://lettre.github.io/lettre/sending-messages/intro/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/sending-messages/intro/ This mailer contains several different transports for your emails. To be sendable, the emails have to implement SendableEmail, which is the case for emails created with lettre_email. The following transports are available: The SmtpTransport uses the SMTP protocol to send the message over the network. It is the prefered way of sending emails. The SendmailTransport uses the sendmail command to send messages. It is an alternative to the SMTP transport. SMTP transport https://lettre.github.io/lettre/sending-messages/smtp/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/sending-messages/smtp/ This transport uses the SMTP protocol to send emails over the network (locally or remotely). It is desinged to be: Secured: email are encrypted by default Modern: Unicode support for email content and sender/recipient adresses when compatible Fast: supports tcp connection reuse This client is designed to send emails to a relay server, and should not be used to send emails directly to the destination. The relay server can be the local email server, a specific host or a third-party service. Sendmail transport https://lettre.github.io/lettre/sending-messages/sendmail/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/sending-messages/sendmail/ The sendmail transport sends the email using the local sendmail command. uselettre::sendmail::SendmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =SendmailTransport::new(); letresult =sender.send(email); assert!(result.is_ok()); File transport https://lettre.github.io/lettre/sending-messages/file/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/sending-messages/file/ The file transport writes the emails to the given directory. The name of the file will be message_id.txt. It can be useful for testing purposes, or if you want to keep track of sent messages. usestd::env::temp_dir; uselettre::file::FileEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; // Write to the local temp directory letmutsender =FileEmailTransport::new(temp_dir()); letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letresult =sender.send(email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt: b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost> To: <root@localhost> From: <user@localhost> Subject: Hello Date: Sat, 31 Oct 2015 13:42:19 +0100 Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695. Stub transport https://lettre.github.io/lettre/sending-messages/stub/ Sun, 21 May 2017 23:46:17 +0200 https://lettre.github.io/lettre/sending-messages/stub/ The stub transport only logs message envelope and drops the content. It can be useful for testing purposes. uselettre::stub::StubEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =StubEmailTransport; letresult =sender.send(email); assert!(result.is_ok()); Will log the line: b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>