# 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/
This documentation is written for lettre 0.7. Please use https://docs.rs/lettre/0.6.2/lettre/ for lettre 0.6. 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. use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = SendmailTransport::new(); let result = 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. use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; // Write to the local temp directory let mut sender = FileEmailTransport::new(temp_dir()); let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let result = sender.send(&email); assert!(result.is_ok()); Example result in /tmp/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. use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = StubEmailTransport::new_positive(); let result = sender.send(&email); assert!(result.is_ok()); Will log (when using a logger like env_logger): b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=