pub fn send_formatted_email(
    email_to: String,
    email_subject: String,
    email_name: String,
    options: HashMap<&str, &str>
) -> Result<lettre::smtp::response::Response> {
    let mut email_html = std::fs::read_to_string(format!("emails/{}.html", email_name))?;
    let mut email_text = std::fs::read_to_string(format!("emails/{}.txt", email_name))?;

    for (key, value) in options.iter() {
        let key_search = format!("{{{}}}", key);
        email_html = str::replace(&email_html[..], &key_search[..], value);
        email_text = str::replace(&email_text[..], &key_search[..], value);
    }

    let result = send_email(email_to, email_subject, email_html, email_text)?;

    Ok(result)
}
/// Sends an email in the `/emails` directory, replacing placeholder values in the HTML and text representations of the email
/// 
/// # Arguments
/// 
/// * `email_to` - The address to send the email to
/// * `email_subject` - The subject line of the email
/// * `email_name` - The name of the email files in the emails directory
/// * `options` - Key-value pairs of the placeholders and their values
/// 
/// # Placeholder example
/// 
/// In the HTML and text email files, the following could be used to insert placeholder values:
/// 
/// `Hello, {firstname} {lastname}. You have received the message: {message}.`
/// 
/// The `options` parameter could then contain values for `firstname`, `lastname`, and `message`.
Sends an email in the `/emails` directory, replacing placeholder values in the HTML and text representations of the email
Sends an email in the ` / emails ` directory replacing placeholder values in the HTML and text representations of the email
pub fn send_formatted_email(
    email_to: String,
    email_subject: String,
    email_name: String,
    options: HashMap<&str, &str>
) -> Result<lettre::smtp::response::Response> {
    let mut email_html = std::fs::read_to_string(format!("emails/{}.html", email_name))?;
    let mut email_text = std::fs::read_to_string(format!("emails/{}.txt", email_name))?;
    for (key, value) in options.iter() {
        let key_search = format!("{{{}}}", key);
        email_html = str::replace(&email_html[..], &key_search[..], value);
        email_text = str::replace(&email_text[..], &key_search[..], value);
    }
    let result = send_email(email_to, email_subject, email_html, email_text)?;
    Ok(result)
}
pub fn send_formatted_email ( email_to : String , email_subject : String , email_name : String , options : HashMap < & str , & str > ) -> Result < lettre :: smtp :: response :: Response > { let mut email_html = std :: fs :: read_to_string ( format ! ( " " email_name ) ) ? ; let mut email_text = std :: fs :: read_to_string ( format ! ( " " email_name ) ) ? ; for ( key , value ) in options . iter ( ) { let key_search = format ! ( " " key ) ; email_html = str :: replace ( & email_html [ .. ] , & key_search [ .. ] , value ) ; email_text = str :: replace ( & email_text [ .. ] , & key_search [ .. ] , value ) ; } let result = send_email ( email_to , email_subject , email_html , email_text ) ? ; Ok ( result ) }
Sends an email in the `/emails` directory, replacing placeholder values in the HTML and text representations of the email
Sends an email in the ` / emails ` directory replacing placeholder values in the HTML and text representations of the email
email_to
String
email_subject
String
email_name
String
options
HashMap<&str, &str>
email_to
String
email_subject
String
email_name
String
options
HashMap<&str, &str>
placeholder example
In the HTML and text email files, the following could be used to insert placeholder values.

`Hello, {firstname} {lastname}. You have received the message: {message}.`

The `options` parameter could then contain values for `firstname`, `lastname`, and `message`.
In the HTML and text email files the following could be used to insert placeholder values . ` Hello { firstname } { lastname } . You have received the message : { message } . ` The ` options ` parameter could then contain values for ` firstname ` ` lastname ` and ` message ` .