OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
knoblyExpressLandingPage
/
vendor
/
phpmailer
/
phpmailer
/
examples
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/21/2024 10:02:44 AM
rwxr-xr-x
📄
DKIM_gen_keys.phps
3.32 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
DKIM_sign.phps
1.77 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
README.md
8 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
azure_xoauth2.phps
4.08 KB
08/21/2024 10:02:39 AM
rw-r--r--
📄
callback.phps
2.31 KB
08/21/2024 10:02:39 AM
rw-r--r--
📄
contactform-ajax.phps
5.14 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
contactform.phps
3.61 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
contents.html
585 bytes
08/21/2024 10:02:40 AM
rw-r--r--
📄
contentsutf8.html
1.15 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
exceptions.phps
1.66 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
extending.phps
2.63 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
gmail.phps
3.76 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
gmail_xoauth.phps
3.91 KB
08/21/2024 10:02:40 AM
rw-r--r--
📁
images
-
08/21/2024 10:04:07 AM
rwxr-xr-x
📄
mail.phps
1.15 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
mailing_list.phps
3.21 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
pop_before_smtp.phps
2.43 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
send_file_upload.phps
2.08 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
send_multiple_file_upload.phps
2.04 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
sendmail.phps
1.22 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
sendoauth2.phps
4.57 KB
08/21/2024 10:02:40 AM
rw-r--r--
📄
simple_contact_form.phps
3.91 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
smime_signed_mail.phps
4.28 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
smtp.phps
2.25 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
smtp_check.phps
2.07 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
smtp_low_memory.phps
4.93 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
smtp_no_auth.phps
1.87 KB
08/21/2024 10:02:41 AM
rw-r--r--
📄
ssl_options.phps
2.36 KB
08/21/2024 10:02:41 AM
rw-r--r--
Editing: extending.phps
Close
<?php /** * This example shows how to extend PHPMailer to simplify your coding. * If PHPMailer doesn't do something the way you want it to, or your code * contains too much boilerplate, don't edit the library files, * create a subclass instead and customise that. * That way all your changes will be retained when PHPMailer is updated. */ //Import PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; require '../vendor/autoload.php'; /** * Use PHPMailer as a base class and extend it */ class MyPHPMailer extends PHPMailer { /** * myPHPMailer constructor. * * @param bool|null $exceptions * @param string $body A default HTML message body */ public function __construct($exceptions, $body = '') { //Don't forget to do this or other things may not be set correctly! parent::__construct($exceptions); //Set a default 'From' address $this->setFrom('joe@example.com', 'Joe User'); //Send via SMTP $this->isSMTP(); //Equivalent to setting `Host`, `Port` and `SMTPSecure` all at once $this->Host = 'tls://smtp.example.com:587'; //Set an HTML and plain-text body, import relative image references $this->msgHTML($body, './images/'); //Show debug output $this->SMTPDebug = SMTP::DEBUG_SERVER; //Inject a new debug output handler $this->Debugoutput = static function ($str, $level) { echo "Debug level $level; message: $str\n"; }; } //Extend the send function public function send() { $this->Subject = '[Yay for me!] ' . $this->Subject; $r = parent::send(); echo 'I sent a message with subject ' . $this->Subject; return $r; } } //Now creating and sending a message becomes simpler when you use this class in your app code try { //Instantiate your new class, making use of the new `$body` parameter $mail = new myPHPMailer(true, '<strong>This is the message body</strong>'); //Now you only need to set things that are different from the defaults you defined $mail->addAddress('jane@example.com', 'Jane User'); $mail->Subject = 'Here is the subject'; $mail->addAttachment(__FILE__, 'myPHPMailer.php'); $mail->send(); //No need to check for errors - the exception handler will do it } catch (Exception $e) { //Note that this is catching the PHPMailer Exception class, not the global \Exception type! echo 'Caught a ' . get_class($e) . ': ' . $e->getMessage(); }