Code formatting
This commit is contained in:
@@ -50,9 +50,10 @@ fn main() {
|
||||
|
||||
let program = args[0].clone();
|
||||
let description = format!("Usage: {0} [options...] recipients\n\n\
|
||||
This program reads a message on standard input until it reaches EOF,\
|
||||
then tries to send it using the given paramters.\n\n\
|
||||
Example: {0} -r user@example.org user@example.com < message.txt", program);
|
||||
This program reads a message on standard input until it reaches\
|
||||
EOF, then tries to send it using the given paramters.\n\n\
|
||||
Example: {0} -r user@example.org user@example.com < message.txt",
|
||||
program);
|
||||
|
||||
let opts = [
|
||||
optopt("r", "reverse-path", "set the sender address", "FROM_ADDRESS"),
|
||||
|
||||
@@ -66,7 +66,9 @@ macro_rules! fail_with_err (
|
||||
macro_rules! check_command_sequence (
|
||||
($command: ident $client: ident) => ({
|
||||
if !$client.state.is_command_allowed(&$command) {
|
||||
fail_with_err!(Response{code: 503, message: Some("Bad sequence of commands".to_string())} $client);
|
||||
fail_with_err!(
|
||||
Response{code: 503, message: Some("Bad sequence of commands".to_string())} $client
|
||||
);
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -98,7 +100,6 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
/// Sends an email
|
||||
pub fn send_mail<S>(&mut self, from_address: &str,
|
||||
to_addresses: &[&str], message: &str) -> SmtpResult {
|
||||
|
||||
// Connect to the server
|
||||
try!(self.connect());
|
||||
|
||||
@@ -199,7 +200,7 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
),
|
||||
None => self.stream.as_mut().unwrap().send_and_get_response(
|
||||
command.to_string().as_slice(), CRLF
|
||||
)
|
||||
),
|
||||
});
|
||||
|
||||
let checked_result = try!(command.test_success(result));
|
||||
@@ -244,7 +245,7 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
name: get_first_word(result.message.as_ref().unwrap().as_slice()).to_string(),
|
||||
esmtp_features: Extension::parse_esmtp_response(
|
||||
result.message.as_ref().unwrap().as_slice()
|
||||
)
|
||||
),
|
||||
}
|
||||
);
|
||||
Ok(result)
|
||||
@@ -257,7 +258,7 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
Some(info) => info,
|
||||
None => fail_with_err!(Response{
|
||||
code: 503,
|
||||
message: Some("Bad sequence of commands".to_string())
|
||||
message: Some("Bad sequence of commands".to_string()),
|
||||
} self),
|
||||
};
|
||||
|
||||
@@ -292,7 +293,7 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
Some(info) => info,
|
||||
None => fail_with_err!(Response{
|
||||
code: 503,
|
||||
message: Some("Bad sequence of commands".to_string())
|
||||
message: Some("Bad sequence of commands".to_string()),
|
||||
} self)
|
||||
};
|
||||
|
||||
@@ -308,7 +309,7 @@ impl<S: Connecter + ClientStream + Clone> Client<S> {
|
||||
Some(extension::Size(max)) if message_content.len() > max =>
|
||||
fail_with_err!(Response{
|
||||
code: 552,
|
||||
message: Some("Message exceeds fixed maximum message size".to_string())
|
||||
message: Some("Message exceeds fixed maximum message size".to_string()),
|
||||
} self),
|
||||
_ => ()
|
||||
};
|
||||
|
||||
@@ -157,10 +157,13 @@ mod test {
|
||||
assert!(super::ExtendedHello("my_name".to_string()).is_ascii());
|
||||
assert!(!super::ExtendedHello("my_namé".to_string()).is_ascii());
|
||||
assert!(
|
||||
super::Mail("test".to_string(), Some(vec!["option".to_string(), "option2".to_string()]))
|
||||
super::Mail("test".to_string(), Some(vec!["test".to_string(), "test".to_string()]))
|
||||
.is_ascii());
|
||||
assert!(
|
||||
!super::Mail("test".to_string(), Some(vec!["option".to_string(), "option2à".to_string()]))
|
||||
!super::Mail("test".to_string(), Some(vec!["est".to_string(), "testà".to_string()]))
|
||||
.is_ascii());
|
||||
assert!(
|
||||
!super::Mail("testé".to_string(), Some(vec!["est".to_string(), "test".to_string()]))
|
||||
.is_ascii());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
//! # Rust SMTP library
|
||||
//!
|
||||
//! The client does its best to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still
|
||||
//! The client should tend to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still
|
||||
//! a work in progress.
|
||||
//!
|
||||
//! It will eventually implement the following extensions :
|
||||
//! It may eventually implement the following extensions :
|
||||
//!
|
||||
//! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152))
|
||||
//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
|
||||
@@ -36,9 +36,9 @@
|
||||
//! Some("myhost"), // my hostname (default is localhost)
|
||||
//! );
|
||||
//! let result = email_client.send_mail::<TcpStream>(
|
||||
//! "user@example.com", // sender (reverse-path)
|
||||
//! "user@example.com", // sender (reverse-path)
|
||||
//! ["user@example.org"], // recipient list
|
||||
//! "Test email", // email content
|
||||
//! "Test email", // email content
|
||||
//! );
|
||||
//! ```
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user