PHP code example of stevegrunwell / mailto-link-formatter

1. Go to this page and download the library: Download stevegrunwell/mailto-link-formatter 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/ */

    

stevegrunwell / mailto-link-formatter example snippets


use SteveGrunwell\MailToLinkFormatter\MailTo;

$mailto = new MailTo;
$mailto->setRecipients('[email protected]');
$mailto->setHeaders([
    'subject' => 'Hello World!',
    'cc'      => '[email protected]',
]);
$mailto->setBody('Some message.');

$mailto->getLink();
# => mailto:[email protected]?subject=Hello%20World!&cc=foo%40example.com&body=Some%20message.

use SteveGrunwell\MailToLinkFormatter\MailTo;

$mailto = new MailTo;

// The same as calling $mailto->setRecipients('[email protected]').
$mailto->recipients = '[email protected]';

// The same as calling $mailto->getRecipients().
$mailto->recipients
# => ['[email protected]']

use SteveGrunwell\MailToLinkFormatter\MailTo;

$mailto = new MailTo;
$mailto->subject = 'Message subject';

$mailto->getHeaders();
# => ['subject' => 'Message subject']

use SteveGrunwell\MailToLinkFormatter\MailTo;

$mailto = new MailTo;
$mailto->setRecipients([
    '[email protected]',
    '[email protected]',
]);

$mailto->getLink();
# => mailto:[email protected],[email protected]

use SteveGrunwell\MailToLinkFormatter\MailTo;

$mailto = new MailTo('[email protected]', [
    'subject' => 'Hello World!',
    'cc'      => '[email protected]',
], 'This is the message body.');

// This is equivalent to:
$mailto = new MailTo;
$mailto->setRecipients('[email protected]');
$mailto->setHeaders([
    'subject' => 'Hello World!',
    'cc'      => '[email protected]',
]);
$mailto->setBody('This is the message body.');