PHP code example of pulli / emate
1. Go to this page and download the library: Download pulli/emate 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/ */
pulli / emate example snippets
use Pulli\Emate\Emate;
// Creates symlink at $HOME/bin/emate (default)
Emate::symlink();
// Or specify a custom directory
Emate::symlink('/usr/local/bin');
use Pulli\Emate\Emate;
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Hello',
'body' => 'This is the email body.',
])->mail();
Emate::from([
'to' => 'John Doe <[email protected] >',
'from' => '[email protected] ',
'subject' => 'Hello John',
'body' => 'Hi there!',
])->mail();
// As an array
Emate::from([
'to' => ['[email protected] ', 'Bob <[email protected] >'],
'from' => '[email protected] ',
'subject' => 'Group message',
'body' => 'Hello everyone!',
])->mail();
// As a newline-separated string
Emate::from([
'to' => "[email protected] \nBob <[email protected] >",
'from' => '[email protected] ',
'subject' => 'Group message',
'body' => 'Hello everyone!',
])->mail();
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'cc' => ['[email protected] ', '[email protected] '],
'bcc' => '[email protected] ',
'subject' => 'Update',
'body' => 'Please see the update.',
])->mail();
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'reply_to' => '[email protected] ',
'subject' => 'Hello',
'body' => 'Please reply to the other address.',
])->mail();
use Symfony\Component\Mime\Address;
Emate::from([
'to' => new Address('[email protected] ', 'Recipient'),
'from' => new Address('[email protected] ', 'Sender'),
'reply_to' => new Address('[email protected] ', 'Reply Handler'),
'subject' => 'Hello',
'body' => 'Using Address objects.',
])->mail();
// As an array
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Files attached',
'body' => 'See attached.',
'files' => ['/path/to/report.pdf', '/path/to/data.csv'],
])->mail();
// As a newline-separated string
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'File attached',
'body' => 'See attached.',
'files' => '/path/to/report.pdf',
])->mail();
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Formatted email',
'body' => "# Heading\n\nThis is **bold** and this is *italic*.",
'markdown' => true,
])->mail();
use Pulli\Emate\EncryptionMode;
// Encrypt with OpenPGP (default)
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Secret',
'body' => 'Encrypted content.',
'encrypt' => true,
])->mail();
// Sign with OpenPGP (default)
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Signed',
'body' => 'Verified content.',
'sign' => true,
])->mail();
// Encrypt and sign with OpenPGP (default)
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Secure',
'body' => 'Encrypted and signed.',
'encrypt' => true,
'sign' => true,
])->mail();
// Sign with S/MIME
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Signed',
'body' => 'Verified content.',
'sign' => true,
'encryption_mode' => 'smime',
])->mail();
// Encrypt and sign with S/MIME, using the enum directly
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Secure',
'body' => 'Encrypted and signed.',
'encrypt' => true,
'sign' => true,
'encryption_mode' => EncryptionMode::SMIME,
])->mail();
// Set a text signature
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Hello',
'body' => 'Email body.',
'signature' => 'Best regards, PuLLi',
])->mail();
// Reference an existing signature by UUID
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Hello',
'body' => 'Email body.',
'signature' => 'uuid:12345-abcde',
])->mail();
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Hello',
'body' => 'Email body.',
'headers' => ['X-Priority: 1', 'X-Mailer: My App'],
])->mail();
Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Urgent',
'body' => 'This sends immediately without queuing in drafts.',
'send_now' => true,
])->mail();
use Pulli\Emate\Emate;
use Pulli\Emate\EncryptionMode;
// Basic email
Emate::compose()
->to('[email protected] ')
->sender('[email protected] ')
->subject('Hello')
->body('This is the email body.')
->mail();
// With all options
Emate::compose()
->to(['[email protected] ', 'Bob <[email protected] >'])
->sender('[email protected] ')
->cc('[email protected] ')
->bcc('[email protected] ')
->replyTo('[email protected] ')
->subject('Full example')
->body('# Heading\n\nMarkdown body.')
->files(['/path/to/report.pdf'])
->markdown()
->encrypt()
->sign()
->sendNow()
->encryptionMode(EncryptionMode::SMIME)
->signature('Best regards')
->header('X-Priority', '1')
->mail();
$command = Emate::from([
'to' => '[email protected] ',
'from' => '[email protected] ',
'subject' => 'Test',
'body' => 'Hello',
])->debug();
echo $command;
// echo 'Hello' | $HOME/bin/emate mailto --to '[email protected] ' --subject 'Test' --from '[email protected] ' --noencrypt --nosign