Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function envia_email($dest, $assunto, $nome_receptor, $template_path, $dados){
- $CI =& get_instance();
- $user = $CI->config->item('smtp_user');
- $passwd = $CI->config->item('smtp_passwd');
- $host = $CI->config->item('smtp_host');
- $port = $CI->config->item('smtp_port');
- $tpl_path = FCPATH . 'templates/';
- $site_url = site_url();
- $base_path = base_url();
- $template = processa_template(
- array('NOME' => $dados['nome'],
- 'URL' => $site_url,
- 'PATH' => $base_path
- ),
- 'resposta_cadastro.php'
- );
- $mail = new PHPMailer(true);
- // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 0; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = $host; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = $user; // SMTP username
- $mail->Password = $passwd; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;
- $mail->CharSet = 'UTF-8';
- //Recipients
- $mail->setFrom($user, $nome_receptor);
- $mail->addAddress($dest, $dados['nome']); // Add a recipient
- // Name is optional
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $assunto;
- $mail->Body = $template;
- //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- return TRUE;
- } catch (Exception $e) {
- echo FALSE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement