1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//! # Mailtrap
//!
//! `mailtrap` is an unofficial Rust library for interacting with the [Mailtrap](https://mailtrap.io) API.
//! It allows you to create and send emails programmatically, manage accounts, and handle access permissions.
//!
//! ## Usage
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! mailtrap = "0.3.1"
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! ## Examples
//!
//! ### Basic Email Sending
//!
//! ```rust,no_run
//! use mailtrap::Email;
//!
//! #[tokio::main]
//! async fn main() {
//! let email = Email::new()
//! .from("sender@example.com")
//! .to("recipient@example.com")
//! .subject("Hello from Rust")
//! .text("This is a test email sent from Rust using the Mailtrap API.")
//! .category("test");
//!
//! // send returns a Result<bool, Error>
//! let res = email.send(
//! None, // Use default API URL
//! Some("YOUR_API_TOKEN"),
//! None
//! ).await;
//!
//! match res {
//! Ok(success) => {
//! if success {
//! println!("Email sent successfully!");
//! } else {
//! println!("Failed to send email.");
//! }
//! }
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
//!
//! ### Advanced Email (Attachments, HTML, Headers)
//!
//! ```rust,no_run
//! use mailtrap::{Email, Attachment, ContentType, Disposition};
//!
//! #[tokio::main]
//! async fn main() {
//! let attachment = Attachment::new()
//! .content("Attachment content".as_bytes().to_vec())
//! .filename("test.txt")
//! .content_type(ContentType::Plain)
//! .disposition(Disposition::Attachment);
//!
//! let email = Email::new()
//! .from("sender@example.com")
//! .to("recipient@example.com")
//! .subject("Advanced Email Test")
//! .text("Plain text content")
//! .html("<h1>HTML Content</h1>")
//! .attachments(vec![attachment])
//! .header("X-Custom-Header", "Custom Value");
//!
//! let res = email.send(None, Some("YOUR_API_TOKEN"), None).await;
//!
//! match res {
//! Ok(_) => println!("Advanced email sent!"),
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
//!
//! ### Batch Sending and Templates
//!
//! ```rust,no_run
//! use mailtrap::{BatchEmail, BatchEmailRequest};
//!
//! #[tokio::main]
//! async fn main() {
//! let request1 = BatchEmailRequest::new()
//! .to("recipient1@example.com")
//! .template_uuid("YOUR_TEMPLATE_UUID")
//! .template_variable("user_name", "Alice");
//!
//! let request2 = BatchEmailRequest::new()
//! .to("recipient2@example.com")
//! .template_uuid("YOUR_TEMPLATE_UUID")
//! .template_variable("user_name", "Bob");
//!
//! let batch_email = BatchEmail::new()
//! .from("sender@example.com")
//! .template_uuid("YOUR_TEMPLATE_UUID")
//! .request(request1)
//! .request(request2);
//!
//! let res = batch_email.send(None, Some("YOUR_API_TOKEN"), None).await;
//!
//! match res {
//! Ok(_) => println!("Batch email sent!"),
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
//!
//! ### Account Access
//!
//! ```rust,no_run
//! use mailtrap::Access;
//!
//! #[tokio::main]
//! async fn main() {
//! let access = Access::new();
//! let account_id = "YOUR_ACCOUNT_ID";
//!
//! // List access permissions
//! let res = access.list(
//! None,
//! Some("YOUR_API_TOKEN"),
//! None,
//! account_id,
//! None, None, None
//! ).await;
//!
//! match res {
//! Ok(records) => println!("Found {} access records", records.len()),
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
//!
//! ### Accounts
//!
//! ```rust,no_run
//! use mailtrap::Accounts;
//!
//! #[tokio::main]
//! async fn main() {
//! let accounts_client = Accounts::new();
//!
//! // List available accounts
//! let res = accounts_client.list(
//! None,
//! Some("YOUR_API_TOKEN"),
//! None
//! ).await;
//!
//! match res {
//! Ok(accounts) => {
//! for account in accounts {
//! println!("Account: {}", account.name);
//! }
//! }
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
pub use *;
pub use *;
pub use *;