mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-08 15:23:14 +00:00
proxmox/src/tools/email.rs: use slice instead of Vec
This commit is contained in:
parent
2702a2a7b5
commit
48d049d4bf
@ -9,7 +9,7 @@ use std::process::{Command, Stdio};
|
|||||||
///
|
///
|
||||||
/// ``sendmail`` is used for sending the mail.
|
/// ``sendmail`` is used for sending the mail.
|
||||||
pub fn sendmail(
|
pub fn sendmail(
|
||||||
mailto: Vec<&str>,
|
mailto: &[&str],
|
||||||
subject: &str,
|
subject: &str,
|
||||||
text: Option<&str>,
|
text: Option<&str>,
|
||||||
html: Option<&str>,
|
html: Option<&str>,
|
||||||
@ -22,7 +22,7 @@ pub fn sendmail(
|
|||||||
bail!("At least one recipient has to be specified!")
|
bail!("At least one recipient has to be specified!")
|
||||||
}
|
}
|
||||||
|
|
||||||
for recipient in &mailto {
|
for recipient in mailto {
|
||||||
if !mail_regex.is_match(recipient) {
|
if !mail_regex.is_match(recipient) {
|
||||||
bail!("'{}' is not a valid email address", recipient)
|
bail!("'{}' is not a valid email address", recipient)
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test1() {
|
fn test1() {
|
||||||
let result = sendmail(
|
let result = sendmail(
|
||||||
vec!["somenotvalidemail!", "somealmostvalid email"],
|
&["somenotvalidemail!", "somealmostvalid email"],
|
||||||
"Subject1",
|
"Subject1",
|
||||||
Some("TEXT"),
|
Some("TEXT"),
|
||||||
Some("<b>HTML</b>"),
|
Some("<b>HTML</b>"),
|
||||||
@ -141,7 +141,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test2() {
|
fn test2() {
|
||||||
let result = sendmail(
|
let result = sendmail(
|
||||||
vec![],
|
&[],
|
||||||
"Subject2",
|
"Subject2",
|
||||||
None,
|
None,
|
||||||
Some("<b>HTML</b>"),
|
Some("<b>HTML</b>"),
|
||||||
@ -154,7 +154,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test3() {
|
fn test3() {
|
||||||
let result = sendmail(
|
let result = sendmail(
|
||||||
vec!["a@b.c"],
|
&["a@b.c"],
|
||||||
"Subject3",
|
"Subject3",
|
||||||
None,
|
None,
|
||||||
Some("<b>HTML</b>"),
|
Some("<b>HTML</b>"),
|
||||||
|
Loading…
Reference in New Issue
Block a user