PHP code example of clinically-au / laravel-smtp2go
1. Go to this page and download the library: Download clinically-au/laravel-smtp2go library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Mail\Mailables\Attachment;
class InvoiceEmail extends Mailable
{
public function content()
{
return new Content(
view: 'emails.invoice',
);
}
public function attachments()
{
return [
Attachment::fromPath('/path/to/invoice.pdf'),
];
}
}
class WelcomeEmail extends Mailable
{
public function content()
{
return new Content(
view: 'emails.welcome.html',
text: 'emails.welcome.text',
);
}
}
use Illuminate\Support\Facades\Mail;
use App\Mail\OrderConfirmation;
public function test_order_sends_confirmation_email()
{
Mail::fake();
// Perform action that sends email
$this->post('/orders', $orderData);
// Assert email was sent
Mail::assertSent(OrderConfirmation::class, function ($mail) {
return $mail->hasTo('[email protected]');
});
}