Fix Email Sender

This commit is contained in:
Alexis Mousset
2015-03-04 14:04:08 +01:00
parent 2fa499629d
commit 3a86f09475
4 changed files with 8 additions and 7 deletions

View File

@@ -37,7 +37,7 @@ fn sendmail(source_address: String, recipient_addresses: Vec<String>, message: S
.subject(subject.as_slice())
.build();
let mut client = ClientBuilder::new((server.as_slice(), port)).hello_name(my_hostname)
let mut client = ClientBuilder::new((server.as_slice(), port)).hello_name(my_hostname.as_slice())
.enable_connection_reuse(true).build();
for _ in range(1, number) {

View File

@@ -72,8 +72,8 @@ impl ClientBuilder {
}
/// Set the name used during HELO or EHLO
pub fn hello_name(mut self, name: String) -> ClientBuilder {
self.hello_name = name;
pub fn hello_name(mut self, name: &str) -> ClientBuilder {
self.hello_name = name.to_string();
self
}
@@ -90,8 +90,8 @@ impl ClientBuilder {
}
/// Set the client credentials
pub fn credentials(mut self, username: String, password: String) -> ClientBuilder {
self.credentials = Some((username, password));
pub fn credentials(mut self, username: &str, password: &str) -> ClientBuilder {
self.credentials = Some((username.to_string(), password.to_string()));
self
}

View File

@@ -73,9 +73,9 @@
//! // Connect to a remote server on a custom port
//! let mut client = ClientBuilder::new(("server.tld", 10025))
//! // Set the name sent during EHLO/HELO, default is `localhost`
//! .hello_name("my.hostname.tld".to_string())
//! .hello_name("my.hostname.tld")
//! // Add credentials for authentication
//! .credentials("username".to_string(), "password".to_string())
//! .credentials("username", "password")
//! // Enable connection reuse
//! .enable_connection_reuse(true).build();
//! let result_1 = client.send(email.clone());

View File

@@ -117,6 +117,7 @@ impl EmailBuilder {
/// Adds a `Sender` header
pub fn sender<A: ToAddress>(mut self, address: A) -> EmailBuilder {
self.content.from = Some(address.to_address().get_address());
self.content.headers.push(
Header::Sender(address.to_address())
);