pub struct OutlookMailer { /* private fields */ }
Expand description
An Outlook mailer client, implementing the async_mailer_core::Mailer
and async_mailer_core::DynMailer
traits
to be used as generic mailer or runtime-pluggable trait object.
Sends mail authenticated by OAuth2 client credentials grant via the Microsoft Graph API.
Implementations§
Source§impl OutlookMailer
impl OutlookMailer
Sourcepub async fn new(
tenant: String,
app_guid: String,
secret: SecretBox<str>,
) -> Result<OutlookMailer, OutlookMailerError>
pub async fn new( tenant: String, app_guid: String, secret: SecretBox<str>, ) -> Result<OutlookMailer, OutlookMailerError>
Create a new Outlook mailer client.
§Errors
Returns an OutlookMailerError::RetrieveAccessToken
error
when the attempt to retrieve an access token from the Microsoft Identity Service fails:
- Wrapping an
OutlookAccessTokenError::SendRequest
error if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponse
error if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponse
error if the response body bytes cannot be parsed as JSON.
Sourcepub async fn new_box(
tenant: String,
app_guid: String,
secret: SecretBox<str>,
) -> Result<Box<dyn DynMailer>, OutlookMailerError>
pub async fn new_box( tenant: String, app_guid: String, secret: SecretBox<str>, ) -> Result<Box<dyn DynMailer>, OutlookMailerError>
Create a new Outlook mailer client as dynamic async_mailer::BoxMailer
.
§Errors
Returns an OutlookMailerError::RetrieveAccessToken
error
when the attempt to retrieve an access token from the Microsoft Identity Service fails:
- Wrapping an
OutlookAccessTokenError::SendRequest
error if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponse
error if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponse
error if the response body bytes cannot be parsed as JSON.
Sourcepub async fn new_arc(
tenant: String,
app_guid: String,
secret: SecretBox<str>,
) -> Result<Arc<dyn DynMailer>, OutlookMailerError>
pub async fn new_arc( tenant: String, app_guid: String, secret: SecretBox<str>, ) -> Result<Arc<dyn DynMailer>, OutlookMailerError>
Create a new Outlook mailer client as dynamic async_mailer::ArcMailer
.
§Errors
Returns an OutlookMailerError::RetrieveAccessToken
error
when the attempt to retrieve an access token from the Microsoft Identity Service fails:
- Wrapping an
OutlookAccessTokenError::SendRequest
error if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponse
error if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponse
error if the response body bytes cannot be parsed as JSON.
Trait Implementations§
Source§impl Clone for OutlookMailer
impl Clone for OutlookMailer
Source§fn clone(&self) -> OutlookMailer
fn clone(&self) -> OutlookMailer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for OutlookMailer
impl Debug for OutlookMailer
Source§impl DynMailer for OutlookMailer
impl DynMailer for OutlookMailer
Source§fn send_mail<'life0, 'life1, 'async_trait>(
&'life0 self,
message: Message<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
OutlookMailer: 'async_trait,
fn send_mail<'life0, 'life1, 'async_trait>(
&'life0 self,
message: Message<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
OutlookMailer: 'async_trait,
Send the prepared MIME message via the Microsoft Graph API.
Dynamically typed DynMailer
implementation for trait object invocation via vtable dispatch.
§Errors
Returns a boxed, type-erased OutlookMailerError::SendMailRequest
error if sending the mailing request to the
Microsoft Graph API fails.
Returns a boxed, type-erased OutlookMailerError::SendMailResponse
error if the Microsoft Graph API responds
with a non-success HTTP status code.
Returns a boxed, type-erased OutlookMailerError::SendMailResponseBody
error if the Microsoft Graph API reponse body
cannot be received.
(Crate feature tracing
only: The response body is only received for logging.)
Source§impl Mailer for OutlookMailer
impl Mailer for OutlookMailer
Source§fn send_mail<'life0, 'life1, 'async_trait>(
&'life0 self,
message: Message<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), <OutlookMailer as Mailer>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
OutlookMailer: 'async_trait,
fn send_mail<'life0, 'life1, 'async_trait>(
&'life0 self,
message: Message<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(), <OutlookMailer as Mailer>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
OutlookMailer: 'async_trait,
Send the prepared MIME message via the Microsoft Graph API.
Statically typed Mailer
implementation for direct
or generic (impl Mailer
/ <M: Mailer>
) invocation without vtable dispatch.
§Errors
Returns an OutlookMailerError::SendMailRequest
error if sending the mailing request to the
Microsoft Graph API fails.
Returns an OutlookMailerError::SendMailResponse
error if the Microsoft Graph API responds
with a non-success HTTP status code.
Returns an OutlookMailerError::SendMailResponseBody
error if the Microsoft Graph API reponse body
cannot be received.
(Crate feature tracing
only: The response body is only received for logging.)