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/ */

    

clinically-au / laravel-smtp2go example snippets


'mailers' => [
    'smtp2go' => [
        'transport' => 'smtp2go',
    ],

    // ... other mailers
],

'default' => env('MAIL_MAILER', 'smtp2go'),

return [
    'endpoint' => env('SMTP2GO_ENDPOINT', 'https://api.smtp2go.com/v3'),
    'api_key' => env('SMTP2GO_API_KEY', ''),
];

use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeEmail;

Mail::to('[email protected]')
    ->send(new WelcomeEmail($user));

Mail::mailer('smtp2go')
    ->to('[email protected]')
    ->send(new InvoicePaid($invoice));

Mail::to($user)
    ->queue(new OrderShipped($order));

Mail::to('[email protected]')
    ->cc('[email protected]')
    ->bcc('[email protected]')
    ->send(new MonthlyReport($data));

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]');
    });
}
bash
php artisan vendor:publish --tag="smtp2go-config"