Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('BASEPATH')) exit('No direct script access allowed');
- class Login extends MX_Controller
- {
- function __construct(){
- parent::__construct();
- $this->load->database();
- }
- function doforgetpass() {
- $from = 'from_mail@gmail.com';
- $to = 'to_mail@gmail.com';
- $subject = 'Test Mail';
- $message = 'Mail content as Plaintext or HTML';
- var_dump( $this->send_mail( $from, $to, $subject, $message ) );
- exit;
- }
- function send_mail($from = null, $to = null, $subject = null, $message = null, $attachment = null) {
- $isReady = false;
- // Config SMTP
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'ssl://smtp.googlemail.com',
- 'smtp_port' => 465,
- 'mailtype' => 'html',
- 'smtp_user' => 'emai@gmail.com', // Email
- 'smtp_pass' => 'password_email' // Email Password
- );
- $this->load->library('email', $config);
- // Validate Params
- if ( !is_null($from) && !is_null($to) && !is_null($subject) && !is_null($message) ) {
- // Set Content
- $this->email->from( $from, 'Mail Sender Name' );
- $this->email->to( $to );
- $this->email->subject( $subject );
- $this->email->message( $message );
- $isReady = true;
- if ( !is_null($attachment) ) {
- if ( is_array($attachment) ) {
- // Set Attachment
- foreach ( $attachment as $key => $item ) {
- $this->email->attach( $item );
- };
- $isReady = true;
- } else {
- $isReady = false;
- };
- };
- };
- // Send Mail
- if ( $isReady == true ) {
- return $this->email->send();
- } else {
- return array('status' => false, 'error' => 'Invalid params.');
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement