Struct async_mailer::OutlookMailer
source · 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: Secret<String>
) -> Result<OutlookMailer, OutlookMailerError>
pub async fn new( tenant: String, app_guid: String, secret: Secret<String> ) -> 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::SendRequesterror if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponseerror if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponseerror if the response body bytes cannot be parsed as JSON.
sourcepub async fn new_box(
tenant: String,
app_guid: String,
secret: Secret<String>
) -> Result<Box<dyn DynMailer>, OutlookMailerError>
pub async fn new_box( tenant: String, app_guid: String, secret: Secret<String> ) -> 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::SendRequesterror if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponseerror if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponseerror if the response body bytes cannot be parsed as JSON.
sourcepub async fn new_arc(
tenant: String,
app_guid: String,
secret: Secret<String>
) -> Result<Arc<dyn DynMailer>, OutlookMailerError>
pub async fn new_arc( tenant: String, app_guid: String, secret: Secret<String> ) -> 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::SendRequesterror if sending the token request fails. - Wrapping an
OutlookAccessTokenError::ReceiveResponseerror if the response body cannot be received. - Wrapping an
OutlookAccessTokenError::ParseResponseerror 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 + Send + Sync>>> + 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 + Send + Sync>>> + 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.)