-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-send.php
More file actions
32 lines (25 loc) · 1012 Bytes
/
basic-send.php
File metadata and controls
32 lines (25 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use OpenForge\Mailer\Mailer;
$mail = new Mailer(
host: 'smtp.yourhost.com',
username: 'your@email.com',
password: 'yourpassword',
secure: Mailer::SECURE_TLS,
);
// Optional: enable debug mode
$mail->enableDebug(true);
// Basic settings
$mail->setFrom('Your Name <your@email.com>')
->setRecipient(['Recipient Name <recipient@example.com>']) // or just 'recipient@example.com'
->setReplyTo('support@example.com')
->setSubject('Test Email from OpenForge Mailer')
->setBody("This is a plain-text version of the email.")
->setHTMLBody("<h2>Hello!</h2><p>This is an <strong>HTML email</strong> sent using <code>OpenForge Mailer</code>.</p>");
// Optional features
$mail->setAttachment(__DIR__ . '/sample.pdf');
$mail->enableTrackingPixel('https://yourdomain.com/tracker.php');
$mail->requestReadReceipt(true);
$mail->allowFallbackToMail(true); // fallback to PHP's mail() if SMTP fails
// Send
echo $mail->send();