server = $server; $this->port = $port; $this->username = $username; $this->password = $password; } /*----------------------------------------------------------------------------*/ function sendMail ($data, & $msg) { $mail = new PHPMailer (); $mail->isSMTP (); //$mail->SMTPDebug = SMTP::DEBUG_LOWLEVEL; $mail->Host = $this->server; $mail->Port = $this->port; $mail->SMTPAuth = true; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Username = $this->username; $mail->Password = $this->password; $mail->CharSet = "UTF-8"; $mail->isHTML (true); $mail->setFrom ($data ["from"], $data ["fromname"]); $mail->addAddress ($data ["to"], $data ["toname"]); if (array_key_exists ("cc", $data)) /* cc is optional */ $mail->addCC ($data ["cc"], $data ["ccname"]); $mail->addAttachment ($data ["file"], $data ["filename"]); $mail->Subject = $data ["subject"]; $mail->Body = $data ["body"]; $mail->AltBody = strip_tags (str_replace ("
", "\n", $mail->Body)); if (! $mail->send ()) { $msg = trim ($mail->ErrorInfo); $mail = null; return 0; } $mail = null; $msg = ""; return 1; } } ?>