Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendEmailWithAttach($subject, $body, $to, $add_cc, $file) {
- require_once LIB_DIR.'/phpmailer/class.phpmailer.php';
- try {
- $mail = new PHPMailer(true);
- $mail->IsSMTP();
- $mail->Host = MAIL_HOST;
- $mail->SMTPAuth = true;
- $mail->SMTPDebug = 2;
- $mail->Debugoutput = 'html';
- //$mail->SMTPSecure = "tls";
- $mail->Port = MAIL_PORT;
- $mail->Username = MAIL_USERNAME;
- $mail->Password = MAIL_PASSWORD;
- if ($add_cc) {
- foreach ($add_cc as $c)
- $mail->AddCC($c);
- }
- $mail->AddReplyTo(MAIL_REPLY_TO, MAIL_REPLY_TO_NAME);
- $mail->From = MAIL_FROM;
- $mail->FromName = MAIL_FROM_NAME;
- $mail->AddAddress($to);
- //$mail->AddCC(MAIL_ADMIN);
- $mail->Subject = $subject;
- $mail->CharSet = "utf-8";
- $mail->WordWrap = 80;
- $mail->IsHTML(true);
- $mail->MsgHTML($body, HTML_DIR);
- if (file_exists($file))
- $mail->AddAttachment($file);
- $return = $mail->Send();
- if (!$return) echo "\n *** ".$mail->ErrorInfo . " \n ";
- } catch (phpmailerException $e) {
- echo $e->errorMessage();
- } catch (Exception $e) {
- echo $e->getMessage();
- }
- return $return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement