Getting started

Installation

Install the library using composer. Execute the following command in your command line (in the project root).

$ composer require genkgo/mail

Message Instantiation

Use the formatted message factory to create a message

$message = (new MessageBodyCollection())
    ->withHtml('<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('from@example.com'))
    ->withHeader(To::fromSingleRecipient('to@example.com', 'name'))
    ->withHeader(Cc::fromSingleRecipient('cc@example.com', 'name'));

Send messages via SMTP

To send the message use a transport, e.g. the SMTP transport.

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

$transport->send($message);