pub struct Sender {
pub address: String,
pub name: Option<String>,
pub reply_to: Option<String>,
}
Expand description
Represents email sender information including address, name, and reply-to.
The Sender struct is used in EmailOptions
to specify who the email
appears to be from, which can differ from the actual sending address
managed by SendWithUs.
§Examples
use send_with_us::types::Sender;
// Create a sender with just an email address
let sender = Sender::new("support@company.com");
// Create a sender with a name
let sender = Sender::new("noreply@company.com")
.with_name("Company Support");
// Create a sender with a name and reply-to address
let sender = Sender::new("noreply@company.com")
.with_name("Company Support")
.with_reply_to("support@company.com");
Fields§
§address: String
Sender’s email address
name: Option<String>
Sender’s name (optional)
reply_to: Option<String>
Reply-to address (optional)
Implementations§
Source§impl Sender
impl Sender
Sourcepub fn new(address: impl Into<String>) -> Self
pub fn new(address: impl Into<String>) -> Self
Creates a new sender with the specified email address.
§Arguments
address
- The sender’s email address
§Returns
A new Sender instance with the provided email address
§Examples
use send_with_us::types::Sender;
let sender = Sender::new("support@company.com");
assert_eq!(sender.address, "support@company.com");
assert_eq!(sender.name, None);
assert_eq!(sender.reply_to, None);
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Sets the sender’s name.
This method uses the builder pattern, allowing for method chaining.
§Arguments
name
- The sender’s name
§Returns
Self with the updated name for method chaining
§Examples
use send_with_us::types::Sender;
let sender = Sender::new("support@company.com")
.with_name("Company Support Team");
assert_eq!(sender.name, Some("Company Support Team".to_string()));
Sourcepub fn with_reply_to(self, reply_to: impl Into<String>) -> Self
pub fn with_reply_to(self, reply_to: impl Into<String>) -> Self
Sets the reply-to address.
This address will be used when recipients click “Reply” in their email client.
§Arguments
reply_to
- The email address to use for replies
§Returns
Self with the updated reply-to for method chaining
§Examples
use send_with_us::types::Sender;
let sender = Sender::new("noreply@company.com")
.with_reply_to("support@company.com");
assert_eq!(sender.reply_to, Some("support@company.com".to_string()));
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Sender
impl<'de> Deserialize<'de> for Sender
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Sender
Auto Trait Implementations§
impl Freeze for Sender
impl RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl UnwindSafe for Sender
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more