@@ -115,29 +115,68 @@ public function testSendMultipleEmails(): void
115115 $ this ->assertEquals ('success ' , $ response ['results ' ][1 ]['status ' ], \var_export ($ response , true ));
116116 }
117117
118- public function testSendEmailWithAttachmentsThrowsException (): void
118+ public function testSendEmailWithFileAttachment (): void
119119 {
120- $ this ->expectException (\Exception::class);
121- $ this ->expectExceptionMessage ('Resend does not support attachments at this time ' );
122-
123- $ to = $ this ->testEmail ;
124- $ subject = 'Test Subject ' ;
125- $ content = 'Test Content ' ;
126- $ fromEmail = $ this ->testEmail ;
127-
128120 $ message = new Email (
129- to: [$ to ],
130- subject: $ subject ,
131- content: $ content ,
121+ to: [$ this -> testEmail ],
122+ subject: ' Test File Attachment ' ,
123+ content: ' Test Content with file attachment ' ,
132124 fromName: 'Test Sender ' ,
133- fromEmail: $ fromEmail ,
125+ fromEmail: $ this -> testEmail ,
134126 attachments: [new Attachment (
135127 name: 'image.png ' ,
136128 path: __DIR__ .'/../../../assets/image.png ' ,
137129 type: 'image/png '
138130 )],
139131 );
140132
133+ $ response = $ this ->sender ->send ($ message );
134+
135+ $ this ->assertResponse ($ response );
136+ }
137+
138+ public function testSendEmailWithStringAttachment (): void
139+ {
140+ $ message = new Email (
141+ to: [$ this ->testEmail ],
142+ subject: 'Test String Attachment ' ,
143+ content: 'Test Content with string attachment ' ,
144+ fromName: 'Test Sender ' ,
145+ fromEmail: $ this ->testEmail ,
146+ attachments: [new Attachment (
147+ name: 'test.txt ' ,
148+ path: '' ,
149+ type: 'text/plain ' ,
150+ content: 'Hello, this is a test attachment. ' ,
151+ )],
152+ );
153+
154+ $ response = $ this ->sender ->send ($ message );
155+
156+ $ this ->assertResponse ($ response );
157+ }
158+
159+ public function testSendEmailWithAttachmentExceedingMaxSize (): void
160+ {
161+ $ this ->expectException (\Exception::class);
162+ $ this ->expectExceptionMessage ('Total attachment size exceeds ' );
163+
164+ $ largeContent = \str_repeat ('x ' , 25 * 1024 * 1024 + 1 );
165+
166+ $ message = new Email (
167+ to: [$ this ->testEmail ],
168+ subject: 'Test Oversized Attachment ' ,
169+ content: 'Test Content ' ,
170+ fromName: 'Test Sender ' ,
171+ fromEmail: $ this ->testEmail ,
172+ attachments: [new Attachment (
173+ name: 'large.bin ' ,
174+ path: '' ,
175+ type: 'application/octet-stream ' ,
176+ content: $ largeContent ,
177+ )],
178+ );
179+
141180 $ this ->sender ->send ($ message );
142181 }
143182}
0 commit comments