Server IP : 68.65.122.142 / Your IP : 3.144.23.143 Web Server : LiteSpeed System : Linux server167.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : glenirhm ( 1318) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/glenirhm/mygc.glenbowcollege.ca/common/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php // From PHPMailer code require '../../composer/vendor/autoload.php'; //Import PHPMailer classes into the global namespace //These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\SMTP; // End of 1st part of PHPMailer code function sendEmail($host, $username, $password, $from, $destination, $subject, $body, $screen_message, $attachments) { //Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true); try { //https://stackoverflow.com/questions/3477766/phpmailer-smtp-error-could-not-connect-to-smtp-host $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); //Server settings //$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = $host; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = $username; //SMTP username $mail->Password = $password; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above //Recipients $mail->setFrom($from, 'Glenbow College'); //$mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient $mail->addAddress($destination); //Name is optional //$mail->addReplyTo('info@example.com', 'Information'); //$mail->addCC('cc@example.com'); //$mail->addBCC('bcc@example.com'); //Attachments if (!empty($attachments)) { foreach ($attachments as $attachment) { $mail->addAttachment('attachments/'.$attachment); } } //$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo $screen_message; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } }