PHP code example of adrianorsouza / codeigniter-phpmailer
1. Go to this page and download the library: Download adrianorsouza/codeigniter-phpmailer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adrianorsouza / codeigniter-phpmailer example snippets
$mail = new Mail();
$this->load->library('mail');
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Mailer Configuration
$config['mail_mailer'] = 'PHPMailer';
$config['mail_debug'] = 0; // default: 0, debugging: 2, 'local'
$config['mail_debug_output'] = 'html';
$config['mail_smtp_auth'] = true;
$config['mail_smtp_secure'] = ''; // default: '' | tls | ssl |
$config['mail_charset'] = 'utf-8';
// Templates Path and optional config
$config['mail_template_folder'] = 'templates/email';
$config['mail_template_options'] = array(
'SITE_NAME' => 'Codeigniter Mail Plugin',
'SITE_LOGO' => 'http://localhost/images/logo.jpg',
'BASE_URL' => 'http://localhost',
);
// Server Configuration
$config['mail_smtp'] = 'smtp.example.com';
$config['mail_port'] = 587; // for gmail default 587 with tls
$config['mail_user'] = '[email protected] ';
$config['mail_pass'] = 'secret';
// Mailer config Sender/Receiver Addresses
$config['mail_admin_mail'] = '[email protected] ';
$config['mail_admin_name'] = 'WebMaster';
$config['mail_from_mail'] = '[email protected] ';
$config['mail_from_name'] = 'Site Name';
$config['mail_replyto_mail'] = '[email protected] ';
$config['mail_replyto_name'] = 'Reply to Name';
// BCC and CC Email Addresses
$config['mail_bcc'] = '[email protected] ';
$config['mail_cc'] = '[email protected] ';
// BCC and CC enable config, default disabled;
$config['mail_setBcc'] = false;
$config['mail_setCc'] = false;
/* End of file mail_config.php */
/* Location: ./application/config/mail_config.php */
$data = '<h2>Sample Basic</h2>
<hr>
<p>This is a simple basic mail message in <strong>HTML</strong> string format</p>
<p>Lorem ipsum dolor sit amharum<br /> quod deserunt id dolores.</p>';
$mail = new Mail();
$mail->setMailBody($data);
$mail->sendMail('Awesome Subject', '[email protected] ');
$data = null;
$template_html = 'sample-1.html'; //views/templates/mail/
$mail = new Mail();
$mail->setMailBody($data, $template_html);
$mail->sendMail('Awesome Subject', '[email protected] ');
$data = array(
"NAME" => 'Juliet & Romeo',
"EMAIL" => '[email protected] ',
"MESSAGE" => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
"DATE" => date('Y-m-d H:i:s'),
"SMALL_TEXT" => 'Sapiente, fugiat consequatur illo eaque ipsam expedita sint itaque',
);
$template_html = 'sample-2.html'; //views/templates/mail/
$mail = new Mail();
$mail->setMailBody($data, $template_html);
$mail->sendMail('Awesome Subject', '[email protected] ');
$config = array(
'mail_bcc'=>'[email protected] ',
'mail_setBcc'=>true
);
$mail = new Mail($config);