PHP code example of avzer / mail

1. Go to this page and download the library: Download avzer/mail 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/ */

    

avzer / mail example snippets


$message = (new MessageBodyCollection('<html><body><p>Hello World</p></body></html>'))
    ->withAttachment(new FileAttachment('/order1.pdf', new ContentType('application/pdf')))
    ->createMessage()
    ->withHeader(new Subject('Hello World'))
    ->withHeader(From::fromEmailAddress('[email protected]'))
    ->withHeader(To::fromSingleRecipient('[email protected]', 'name'))
    ->withHeader(Cc::fromSingleRecipient('[email protected]', 'name'));

$transport = new SmtpTransport(
    ClientFactory::fromString('smtp://user:pass@host/')->newClient(),
    EnvelopeFactory::useExtractedHeader()
);

$transport->send($message);