PHP code example of descubraomundo / notifymehq-mail
1. Go to this page and download the library: Download descubraomundo/notifymehq-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/ */
// Create a factory for notifications.
$notifierFactory = new NotifyMeHQ\NotifyMe\NotifyMeFactory();
// Create the new notification for mail.
$mailNotifier = $notifierFactory->make([
// Specify that we will use mail.
'driver' => 'mail',
// Specify your SMTP Server Host.
'host' => '',
// Specify your SMTP Server Port, check with your host. Eg: 25 or 465 or 2525.
'port' => 25,
// Specify your SMTP Server Username.
'username' => '',
// Specify your SMTP Server Password.
'password' => '',
// Specify your Sender details. It can be a simple email, or a email with a name.
'from' => ['[email protected]','Example Sender'], // Email & Name
]);
/**
* RECIPIENTS:
*/
$recipient = ['[email protected]', 'Recipient Name'];
/**
* EMAIL
*/
$email = [
// Specifies the subject line that is displayed in the recipients' mail client
'subject' => 'Test',
// Specifies the body of the email that the recipient will receive.
'body' => [
'html' => 'My <em>amazing</em> body',
'plain' => 'My amazing body'
],
// Specifies the addresses of recipients who will be copied in on the message
'cc' => ['[email protected]', 'CC Name'],
// Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies.
'bcc' => ['[email protected]', 'BCC Name'],
// Specifies the address where replies are sent to
'replyTo' => ['[email protected]', 'Reply To Name'],
// Specifies the sender address if you want to overwrite the value set on the configuration properties.
'from' => ['[email protected]', 'Other Sender Name'],
/**
* ADVANCED OPTIONS
*/
// Specifies the format of the message (usually text/plain or text/html)
'contentType' => 'text/html',
// Specifies where bounces should go (Swift Mailer reads this for other uses)
'returnPath' => '[email protected]',
// Specifies the email priority.
'priority' => '2', // Indicates "High" priority.
];
/* @var \NotifyMeHQ\Contracts\ResponseInterface $response */
$response = $mailNotifier->notify($recipient, $email);
echo $response->isSent() ? 'Message sent' : 'Message going nowhere';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.