function enviamail($dest, $id_gr, $body_mail, $anex) { require '../mail/class.phpmailer.php'; //$emaildest = (string)$dest; $mail = new PHPmailer(); $mail->IsSMTP(); $mail->IsHTML(true); $mail->Helo = $_SESSION['helo_envio_mail_send_supplier']; //$mail->SMTPSecure='SSL'; $mail->Port = $_SESSION['port_envio_mail_send_supplier']; $mail->Username = $_SESSION['login_mail_send_supplier']; $mail->Password = $_SESSION['password_mail_send_supplier']; $mail->Host = $_SESSION['host_envio_mail_send_supplier']; $mail->From = $_SESSION['from_mail_send_supplier']; $mail->SetFrom = $_SESSION['setfrom_mail_send_supplier']; foreach ($dest as $db => $value) { $mail->AddAddress($value); } //$mail->AddAddress($emaildest); $mail->AddCC($_SESSION['addcc_mail_send_supplier']); #$mail->AddReplyTo('*****@*****.**', 'Administrator JO2012'); $mail->Subject = 'GR Nº' . $id_gr; $mail->Body = '<html><body>Bom dia,<br /><br />' . $body_mail . '<br/><br/>Obrigado pela atenção.</body></html>'; $pdf = createpdf($id_gr); $attachment = $pdf->Output('GR numero ' . $id_gr . '.pdf', 'S'); $mail->AddStringAttachment($attachment, 'GR numero ' . $id_gr . '.pdf'); //verifica se existe um talão porque se existe é sempre para enviar if (strpos($id_gr, '-') !== false) { $data = grepGetByGrNumber($id_gr); } else { $data = grepGetById($id_gr); } //$data = grepGetById($id_gr); //$urlguia = $data['url_talao']; if ($data['url_talao'] != "") { $mail->AddAttachment('../' . $data['url_talao'], 'talao.pdf'); } unset($data); if ($anex != '') { $mail->AddAttachment($anex); } if ($mail->Send()) { $mail->ErrorInfo; $mail->SmtpClose(); unset($mail); //$erro = true; #return 'Verifica o email introduzido (ex: meumail@mail.com)'; return false; } else { //$erro = false; $mail->SmtpClose(); unset($mail); #return 'Email enviado com sucesso'; return true; } #$mail->SmtpClose(); #unset($mail); }
function mail_coupon($team, $partner, $order, $user, $coupon) { global $INI; $week = array('S', 'M', 'T', 'W', 'T', 'F', 'S'); $today = date('m.d.Y') . $week[date('w')]; $vars = array('today' => $today, 'team' => $team, 'city' => $city, 'user' => $user, 'partner' => $partner, 'order' => $order, 'coupon' => $coupon, 'help_email' => $INI['subscribe']['helpemail'], 'help_mobile' => $INI['subscribe']['helpphone'], 'notice_email' => $INI['mail']['reply']); $message = render('mail_coupon_info', $vars); //$mesasge = mb_convert_encoding($message, 'GBK', 'UTF-8'); $options = array('contentType' => 'text/html', 'encoding' => 'UTF-8'); $from = $INI['mail']['from']; $to = $user['email']; $subject = $INI['system']['sitename'] . ": Your Coupon Details"; if ($order['isgift'] == 'Y') { $gift = Table::Fetch('order_gift', $order['id'], 'order_id'); if ($gift['delivery'] == "email") { $to = $gift['email']; $subject = "(Your gift from " . $order['realname'] . ")" . $subject; } } $content = createpdf(render('mail_coupon_pdf', $vars)); if ($INI['mail']['mail'] == 'mail') { Mailer::SendMail($from, $to, $subject, $message, $options, array(), $content); } else { Mailer::SmtpMail($from, $to, $subject, $message, $options, null, $content); } }