SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = $SMTP_SERVER; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = $SMTP_USER; //SMTP username $mail->Password = $SMTP_PASS; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = $SMTP_PORT; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom($SMTP_USER, $OJ_NAME ); $mail->addAddress($address, $OJ_NAME.' User'); //Add a recipient // $mail->addAddress('ellen@example.com'); //Name is optional // $mail->addReplyTo('info@example.com', 'Information'); // $mail->addCC('cc@example.com'); // $mail->addBCC('bcc@example.com'); //Attachments //$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name //Content if($html!=""){ $mail->Body= $html; $mail->isHTML(true); //Set email format to HTML }else{ $mail->Body= $mailcontent; $mail->isHTML(false); } $mail->AltBody = $mailcontent; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } }