PHP code example of jiaojie / pop-mail

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

    

jiaojie / pop-mail example snippets


use Pop\Mail\Mail;

$mail = new Mail('Test Email Subject');

$mail->to('[email protected]');
$mail->cc('[email protected]');
$mail->from('[email protected]');

$mail->setText('Hello World! This is a test email.');

$mail->send();

use Pop\Mail\Mail;

$mail = new Mail('Attaching a File');

$mail->to('[email protected]');
$mail->from('[email protected]');

$mail->setText('Check out this file.');
$mail->attachFile('lorem.docx');

$mail->send();

$mail = new Mail('Sending an HTML Email');

$mail->to('[email protected]');
$mail->from('[email protected]');

$html = <<<HTML
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is a cool HTML email, huh?</p>
</body>
</html>
HTML;

$mail->setHtml($html);
$mail->setText(
    'This is the text message in case your email client cannot display HTML.'
);

$mail->send();

use Pop\Mail\Mail;

$mail = new Mail('Test Email Subject');

$mail->to('[email protected]');
$mail->cc('[email protected]');
$mail->from('[email protected]');

$mail->setText('Hello World! This is a test email.');
$mail->saveTo(__DIR__ . '/email-queue');

use Pop\Mail\Mail;

$mail = new Mail();
$mail->sendFrom(__DIR__ . '/email-queue', true);