Skip to content
Derek Jones edited this page Jul 5, 2012 · 11 revisions

Download the distribution. Rename folder, phpmailerv2.3 to phpmailer. Save in Application/plugins directory. Create file and name to phpmailer_pi.php

CREDITS:

[b]Author: Thorpe Obazee

website: pinoytech.org/ doc: Pinoy Smart Life The original PHPMailer package http://phpmailer.codeworxtech.com/[/b]

phpmailer_pi.php

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function send_email($recipient, $sender, $subject, $message)
{
    require_once("phpmailer/class.phpmailer.php");

    $mail = new PHPMailer();
    $body = $message;
    $mail->IsSMTP();
    $mail->FromName = "Bargain Philippines";
    $mail->From = $sender;
    $mail->Subject = $subject;
    $mail->AltBody = strip_tags($message);
    $mail->MsgHTML($body);
    $mail->AddAddress($recipient);
    if ( ! $mail->Send())
    {
        echo 'Failed to Send';
    }
    else
    {
        echo 'Mail Sent';
    }
}
?>

From the controller:

<?php
    public function forgot_password()
    {
           $this->load->plugin('phpmailer');
           send_email('[email protected]', '[email protected]', 'subject', 'message body');
        }

?>
Clone this wiki locally