Adjust the format for better readability (#1687)
Adjust the format for better readability
This commit is contained in:
parent
ba148d590e
commit
fc8c727f38
28
README.md
28
README.md
|
|
@ -89,20 +89,22 @@ While installing the entire package manually or with Composer is simple, conveni
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use PHPMailer\PHPMailer\Exception;
|
use PHPMailer\PHPMailer\Exception;
|
||||||
|
|
||||||
//Load Composer's autoloader
|
// Load Composer's autoloader
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
$mail = new PHPMailer(true); // Passing `true` enables exceptions
|
// Instantiation and passing `true` enables exceptions
|
||||||
|
$mail = new PHPMailer(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Server settings
|
//Server settings
|
||||||
$mail->SMTPDebug = 2; // Enable verbose debug output
|
$mail->SMTPDebug = 2; // Enable verbose debug output
|
||||||
$mail->isSMTP(); // Set mailer to use SMTP
|
$mail->isSMTP(); // Set mailer to use SMTP
|
||||||
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
|
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
|
||||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||||
$mail->Username = 'user@example.com'; // SMTP username
|
$mail->Username = 'user@example.com'; // SMTP username
|
||||||
$mail->Password = 'secret'; // SMTP password
|
$mail->Password = 'secret'; // SMTP password
|
||||||
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||||||
$mail->Port = 587; // TCP port to connect to
|
$mail->Port = 587; // TCP port to connect to
|
||||||
|
|
||||||
//Recipients
|
//Recipients
|
||||||
$mail->setFrom('from@example.com', 'Mailer');
|
$mail->setFrom('from@example.com', 'Mailer');
|
||||||
|
|
@ -112,11 +114,11 @@ try {
|
||||||
$mail->addCC('cc@example.com');
|
$mail->addCC('cc@example.com');
|
||||||
$mail->addBCC('bcc@example.com');
|
$mail->addBCC('bcc@example.com');
|
||||||
|
|
||||||
//Attachments
|
// Attachments
|
||||||
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
|
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
|
||||||
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
|
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
|
||||||
|
|
||||||
//Content
|
// Content
|
||||||
$mail->isHTML(true); // Set email format to HTML
|
$mail->isHTML(true); // Set email format to HTML
|
||||||
$mail->Subject = 'Here is the subject';
|
$mail->Subject = 'Here is the subject';
|
||||||
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
|
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
|
||||||
|
|
@ -125,7 +127,7 @@ try {
|
||||||
$mail->send();
|
$mail->send();
|
||||||
echo 'Message has been sent';
|
echo 'Message has been sent';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
|
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue