pub struct Mailer {
pub username: String,
pub password: String,
pub smtp_server: String,
}
Expand description
Struct used to handle sending emails via a auth smtp server (completely for free)
Fields§
§username: String
§password: String
§smtp_server: String
Implementations§
Source§impl Mailer
impl Mailer
Sourcepub fn new(username: String, password: String, smtp_server: String) -> Self
pub fn new(username: String, password: String, smtp_server: String) -> Self
Creates a new Mailer instance
§Arguments
- username - The username of (ideally) the sender
- password - The password associated with the email account
- smtp_server - The Simple Mail Transfer Protocol server (i.e gmail, etc)
Sourcepub fn send(&self, to: &str, from: &str, subject: &str, text: &str, html: &str)
pub fn send(&self, to: &str, from: &str, subject: &str, text: &str, html: &str)
Send a email (completely for free) with the provided sender and recipient as well as subject + body text + html
Emails will only be sent if the following are all true (1) - The provided Mailer.username is a valid email registered on the specified smtp_server (2) - The email password is correct (if using gmail you will want to see this: https://support.google.com/accounts/answer/185833?hl=en)
§Arguments
to
- a string slice that holds the email address of the intended recipientfrom
- a string slice that specifies the email address of the sendersubject
- subject field of the emailtext
- text content of the emailhtml
- html content of the email
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mailer
impl RefUnwindSafe for Mailer
impl Send for Mailer
impl Sync for Mailer
impl Unpin for Mailer
impl UnwindSafe for Mailer
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