File: smtp_raw_message.rs

package info (click to toggle)
rust-mail-send 0.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: makefile: 2; sh: 1
file content (29 lines) | stat: -rw-r--r-- 806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
 *
 * SPDX-License-Identifier: Apache-2.0 OR MIT
 */

use mail_send::SmtpClientBuilder;
use mail_send::smtp::message::Message;

#[tokio::main]
async fn main() {
    // Build a raw message
    let message = Message::empty()
        .from("jdoe@example.com")
        .to("jane@example.com")
        .to("james@smith.com")
        .body(&b"From: jdoe@example.com\nTo: jane@example.com\nSubject: Hi!\n\nHello, world!"[..]);

    // Connect to an SMTP relay server.
    // The library will upgrade the connection to TLS if the server supports it.
    SmtpClientBuilder::new("mail.smtp2go.com", 2525)
        .implicit_tls(false)
        .connect()
        .await
        .unwrap()
        .send(message)
        .await
        .unwrap();
}