sendgrid_api/
settings_mail.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct SettingsMail {
5    pub client: Client,
6}
7
8impl SettingsMail {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        SettingsMail { client }
12    }
13
14    /**
15     * Retrieve all mail settings.
16     *
17     * This function performs a `GET` to the `/mail_settings` endpoint.
18     *
19     * **This endpoint allows you to retrieve a list of all mail settings.**
20     *
21     * Each setting will be returned with an `enabled` status set to `true` or `false` and a short description that explains what the setting does.
22     *
23     * **Parameters:**
24     *
25     * * `limit: i64` -- The number of settings to return.
26     * * `offset: i64` -- Where in the list of results to begin displaying settings.
27     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
28     */
29    pub async fn get_mail_settings(
30        &self,
31        limit: i64,
32        offset: i64,
33    ) -> ClientResult<crate::Response<crate::types::GetMailSettingsResponse>> {
34        let mut query_args: Vec<(String, String)> = Default::default();
35        if limit > 0 {
36            query_args.push(("limit".to_string(), limit.to_string()));
37        }
38        if offset > 0 {
39            query_args.push(("offset".to_string(), offset.to_string()));
40        }
41        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
42        let url = self.client.url(&format!("/mail_settings?{}", query_), None);
43        self.client
44            .get(
45                &url,
46                crate::Message {
47                    body: None,
48                    content_type: None,
49                },
50            )
51            .await
52    }
53    /**
54     * Retrieve address whitelist mail settings.
55     *
56     * This function performs a `GET` to the `/mail_settings/address_whitelist` endpoint.
57     *
58     * **This endpoint allows you to retrieve your current email address whitelist settings.**
59     *
60     * The Address Whitelist setting allows you to specify email addresses or domains for which mail should never be suppressed.
61     *
62     * For example, if you own the domain `example.com`, and one or more of your recipients use `email@example.com` addresses, placing `example.com` in the address whitelist setting instructs Twilio SendGrid to ignore all bounces, blocks, and unsubscribes logged for that domain. In other words, all bounces, blocks, and unsubscribes will still be sent to `example.com` as if they were sent under normal sending conditions.
63     *
64     * **Parameters:**
65     *
66     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
67     */
68    pub async fn get_mail_settings_address_whitelist(
69        &self,
70    ) -> ClientResult<crate::Response<crate::types::MailSettingsAddressWhitelabel>> {
71        let url = self.client.url("/mail_settings/address_whitelist", None);
72        self.client
73            .get(
74                &url,
75                crate::Message {
76                    body: None,
77                    content_type: None,
78                },
79            )
80            .await
81    }
82    /**
83     * Update address whitelist mail settings.
84     *
85     * This function performs a `PATCH` to the `/mail_settings/address_whitelist` endpoint.
86     *
87     * **This endpoint allows you to update your current email address whitelist settings.**
88     *
89     * You can select whether or not this setting should be enabled by assigning the `enabled` field a `true` or `false` value.
90     *
91     * Passing only the `enabled` field to this endpoint will not alter your current `list` of whitelist entries. However, any modifications to your `list` of entries will overwrite the entire list. For this reason, you must included all existing entries you wish to retain in your `list` in addition to any new entries you intend to add. To remove one or more `list` entries, pass a `list` with only the entries you wish to retain.
92     *
93     * You should not add generic domains such as `gmail.com` or `yahoo.com`  in your `list` because your emails will not honor recipients' unsubscribes. This may cause a legal violation of [CAN-SPAM](https://sendgrid.com/docs/glossary/can-spam/) and could damage your sending reputation.
94     *
95     * The Address Whitelist setting allows you to specify email addresses or domains for which mail should never be suppressed.
96     *
97     * For example, if you own the domain `example.com`, and one or more of your recipients use `email@example.com` addresses, placing `example.com` in the address whitelist setting instructs Twilio SendGrid to ignore all bounces, blocks, and unsubscribes logged for that domain. In other words, all bounces, blocks, and unsubscribes will still be sent to `example.com` as if they were sent under normal sending conditions.
98     *
99     * **Parameters:**
100     *
101     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
102     */
103    pub async fn patch_mail_settings_address_whitelist(
104        &self,
105        body: &crate::types::PatchMailSettingsAddressWhitelistRequest,
106    ) -> ClientResult<crate::Response<crate::types::MailSettingsAddressWhitelabel>> {
107        let url = self.client.url("/mail_settings/address_whitelist", None);
108        self.client
109            .patch(
110                &url,
111                crate::Message {
112                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
113                    content_type: Some("application/json".to_string()),
114                },
115            )
116            .await
117    }
118    /**
119     * Retrieve footer mail settings.
120     *
121     * This function performs a `GET` to the `/mail_settings/footer` endpoint.
122     *
123     * **This endpoint allows you to retrieve your current Footer mail settings.**
124     *
125     * The Footer setting will insert a custom footer at the bottom of your text and HTML email message bodies.
126     *
127     * You can insert your HTML or plain text directly using the "Update footer mail settings" endpoint, or you can create the footer using the [Mail Settings menu in the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).
128     *
129     * **Parameters:**
130     *
131     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
132     */
133    pub async fn get_mail_settings_footer(
134        &self,
135    ) -> ClientResult<crate::Response<crate::types::MailSettingsFooter>> {
136        let url = self.client.url("/mail_settings/footer", None);
137        self.client
138            .get(
139                &url,
140                crate::Message {
141                    body: None,
142                    content_type: None,
143                },
144            )
145            .await
146    }
147    /**
148     * Update footer mail settings.
149     *
150     * This function performs a `PATCH` to the `/mail_settings/footer` endpoint.
151     *
152     * **This endpoint allows you to update your current Footer mail settings.**
153     *
154     * The Footer setting will insert a custom footer at the bottom of your text and HTML email message bodies.
155     *
156     * You can insert your HTML or plain text directly using this endpoint, or you can create the footer using the [Mail Settings menu in the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).
157     *
158     * **Parameters:**
159     *
160     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
161     */
162    pub async fn patch_mail_settings_footer(
163        &self,
164        body: &crate::types::MailSettingsFooter,
165    ) -> ClientResult<crate::Response<crate::types::MailSettingsFooter>> {
166        let url = self.client.url("/mail_settings/footer", None);
167        self.client
168            .patch(
169                &url,
170                crate::Message {
171                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
172                    content_type: Some("application/json".to_string()),
173                },
174            )
175            .await
176    }
177    /**
178     * Retrieve forward spam mail settings.
179     *
180     * This function performs a `GET` to the `/mail_settings/forward_spam` endpoint.
181     *
182     * **This endpoint allows you to retrieve your current Forward Spam mail settings.**
183     *
184     * Enabling the Forward Spam setting allows you to specify `email` addresses to which spam reports will be forwarded. This endpoint returns any email address(es) you have set to receive forwarded spam and an `enabled` status indicating if the setting is active.
185     *
186     * **Parameters:**
187     *
188     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
189     */
190    pub async fn get_mail_settings_forward_spam(
191        &self,
192    ) -> ClientResult<crate::Response<crate::types::MailSettingsForwardSpam>> {
193        let url = self.client.url("/mail_settings/forward_spam", None);
194        self.client
195            .get(
196                &url,
197                crate::Message {
198                    body: None,
199                    content_type: None,
200                },
201            )
202            .await
203    }
204    /**
205     * Update forward spam mail settings.
206     *
207     * This function performs a `PATCH` to the `/mail_settings/forward_spam` endpoint.
208     *
209     * **This endpoint allows you to update your current Forward Spam mail settings.**
210     *
211     * Enabling the Forward Spam setting allows you to specify `email` addresses to which spam reports will be forwarded. You can set multiple addresses by passing this endpoint a comma separated list of emails in a single string.
212     *
213     * ```
214     * {
215     *   "email": "address1@example.com, address2@exapmle.com",
216     *   "enabled": true
217     * }
218     * ```
219     *
220     * The Forward Spam setting may also be used to receive emails sent to `abuse@` and `postmaster@` role addresses if you have authenticated your domain.
221     *
222     * For example, if you authenticated `example.com` as your root domain and set a custom return path of `sub` for that domain, you could turn on Forward Spam, and any emails sent to `abuse@sub.example.com` or `postmaster@sub.example.com` would be forwarded to the email address you entered in the `email` field.
223     *
224     * You can authenticate your domain using the "Authenticate a domain" endpoint or in the [Sender Authentication section of the Twilio SendGrid App](https://app.sendgrid.com/settings/sender_auth). You can also configure the Forward Spam mail settings in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).
225     *
226     * **Parameters:**
227     *
228     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
229     */
230    pub async fn patch_mail_settings_forward_spam(
231        &self,
232        body: &crate::types::MailSettingsForwardSpam,
233    ) -> ClientResult<crate::Response<crate::types::MailSettingsForwardSpam>> {
234        let url = self.client.url("/mail_settings/forward_spam", None);
235        self.client
236            .patch(
237                &url,
238                crate::Message {
239                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
240                    content_type: Some("application/json".to_string()),
241                },
242            )
243            .await
244    }
245    /**
246     * Retrieve legacy template mail settings.
247     *
248     * This function performs a `GET` to the `/mail_settings/template` endpoint.
249     *
250     * **This endpoint allows you to retrieve your current legacy email template settings.**
251     *
252     * This setting refers to our original email templates. We currently support more fully featured [Dynamic Transactional Templates](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/).
253     *
254     * The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. For instructions on using legacy templates, see how to ["Create and Edit Legacy Transactional Templates](https://sendgrid.com/docs/ui/sending-email/create-and-edit-legacy-transactional-templates/). For help migrating to our current template system, see ["Migrating from Legacy Templates"](https://sendgrid.com/docs/ui/sending-email/migrating-from-legacy-templates/).
255     *
256     * **Parameters:**
257     *
258     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
259     */
260    pub async fn get_mail_settings_template(
261        &self,
262    ) -> ClientResult<crate::Response<crate::types::MailSettingsTemplate>> {
263        let url = self.client.url("/mail_settings/template", None);
264        self.client
265            .get(
266                &url,
267                crate::Message {
268                    body: None,
269                    content_type: None,
270                },
271            )
272            .await
273    }
274    /**
275     * Update template mail settings.
276     *
277     * This function performs a `PATCH` to the `/mail_settings/template` endpoint.
278     *
279     * **This endpoint allows you to update your current legacy email template settings.**
280     *
281     * This setting refers to our original email templates. We currently support more fully featured [Dynamic Transactional Templates](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/).
282     *
283     * The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. For instructions on using legacy templates, see how to ["Create and Edit Legacy Transactional Templates](https://sendgrid.com/docs/ui/sending-email/create-and-edit-legacy-transactional-templates/). For help migrating to our current template system, see ["Migrating from Legacy Templates"](https://sendgrid.com/docs/ui/sending-email/migrating-from-legacy-templates/).
284     *
285     * **Parameters:**
286     *
287     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
288     */
289    pub async fn patch_mail_settings_template(
290        &self,
291        body: &crate::types::PatchMailSettingsTemplateRequest,
292    ) -> ClientResult<crate::Response<crate::types::PatchMailSettingsTemplateResponse>> {
293        let url = self.client.url("/mail_settings/template", None);
294        self.client
295            .patch(
296                &url,
297                crate::Message {
298                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
299                    content_type: Some("application/json".to_string()),
300                },
301            )
302            .await
303    }
304    /**
305     * Retrieve bounce purge mail settings.
306     *
307     * This function performs a `GET` to the `/mail_settings/bounce_purge` endpoint.
308     *
309     * **This endpoint allows you to retrieve your current bounce and purge settings.**
310     *
311     * The Bounce Perge setting allows you to set a schedule that Twilio SendGrid will use to automatically delete contacts from your soft and hard bounce suppression lists.
312     *
313     * A hard bounce occurs when an email message has been returned to the sender because the recipient's address is invalid. A hard bounce might occur because the domain name doesn't exist or because the recipient is unknown.
314     *
315     * A soft bounce occurs when an email message reaches the recipient's mail server but is bounced back undelivered before it actually reaches the recipient. A soft bounce might occur because the recipient's inbox is full.
316     *
317     * You can also manage this setting in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings). You can manage your bounces manually using the [Bounces API](https://sendgrid.api-docs.io/v3.0/bounces-api) or the [Bounces menu in the Twilio SendGrid App](https://app.sendgrid.com/suppressions/bounces).
318     *
319     * **Parameters:**
320     *
321     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
322     */
323    pub async fn get_mail_settings_bounce_purge(
324        &self,
325    ) -> ClientResult<crate::Response<crate::types::MailSettingsBouncePurge>> {
326        let url = self.client.url("/mail_settings/bounce_purge", None);
327        self.client
328            .get(
329                &url,
330                crate::Message {
331                    body: None,
332                    content_type: None,
333                },
334            )
335            .await
336    }
337    /**
338     * Update bounce purge mail settings.
339     *
340     * This function performs a `PATCH` to the `/mail_settings/bounce_purge` endpoint.
341     *
342     * **This endpoint allows you to update your current bounce and purge settings.**
343     *
344     * The Bounce Perge setting allows you to set a schedule that Twilio SendGrid will use to automatically delete contacts from your soft and hard bounce suppression lists. The schedule is set in full days by assigning the number of days, an integer, to the `soft_bounces` and/or `hard_bounces` fields.
345     *
346     * A hard bounce occurs when an email message has been returned to the sender because the recipient's address is invalid. A hard bounce might occur because the domain name doesn't exist or because the recipient is unknown.
347     *
348     * A soft bounce occurs when an email message reaches the recipient's mail server but is bounced back undelivered before it actually reaches the recipient. A soft bounce might occur because the recipient's inbox is full.
349     *
350     * You can also manage this setting in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings). You can manage your bounces manually using the [Bounces API](https://sendgrid.api-docs.io/v3.0/bounces-api) or the [Bounces menu in the Twilio SendGrid App](https://app.sendgrid.com/suppressions/bounces).
351     *
352     * **Parameters:**
353     *
354     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
355     */
356    pub async fn patch_mail_settings_bounce_purge(
357        &self,
358        body: &crate::types::MailSettingsBouncePurge,
359    ) -> ClientResult<crate::Response<crate::types::MailSettingsBouncePurge>> {
360        let url = self.client.url("/mail_settings/bounce_purge", None);
361        self.client
362            .patch(
363                &url,
364                crate::Message {
365                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
366                    content_type: Some("application/json".to_string()),
367                },
368            )
369            .await
370    }
371    /**
372     * Retrieve forward bounce mail settings.
373     *
374     * This function performs a `GET` to the `/mail_settings/forward_bounce` endpoint.
375     *
376     * **This endpoint allows you to retrieve your current bounce forwarding mail settings.**
377     *
378     * Enabling the Forward Bounce setting allows you to specify `email` addresses to which bounce reports will be forwarded. This endpoint returns the email address you have set to receive forwarded bounces and an `enabled` status indicating if the setting is active.
379     *
380     * **Parameters:**
381     *
382     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
383     */
384    pub async fn get_mail_settings_forward_bounce(
385        &self,
386    ) -> ClientResult<crate::Response<crate::types::MailSettingsForwardBounce>> {
387        let url = self.client.url("/mail_settings/forward_bounce", None);
388        self.client
389            .get(
390                &url,
391                crate::Message {
392                    body: None,
393                    content_type: None,
394                },
395            )
396            .await
397    }
398    /**
399     * Update forward bounce mail settings.
400     *
401     * This function performs a `PATCH` to the `/mail_settings/forward_bounce` endpoint.
402     *
403     * **This endpoint allows you to update your current bounce forwarding mail settings.**
404     *
405     * Enabling the Forward Bounce setting allows you to specify an `email` address to which bounce reports will be forwarded.
406     *
407     * You can also configure the Forward Spam mail settings in the [Mail Settings section of the Twilio SendGrid App](https://app.sendgrid.com/settings/mail_settings).
408     *
409     * **Parameters:**
410     *
411     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
412     */
413    pub async fn patch_mail_settings_forward_bounce(
414        &self,
415        body: &crate::types::MailSettingsForwardBounce,
416    ) -> ClientResult<crate::Response<crate::types::MailSettingsForwardBounce>> {
417        let url = self.client.url("/mail_settings/forward_bounce", None);
418        self.client
419            .patch(
420                &url,
421                crate::Message {
422                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
423                    content_type: Some("application/json".to_string()),
424                },
425            )
426            .await
427    }
428}