Welcome Guest, Not a member yet? Register   Sign In
Swiftmail Library for CodeIgniter
#1

[eluser]Glazz[/eluser]
Hello,

I was finding problems using the email library from CodeIgniter because the config/email.php file was not working the way it was supposed to, and InsiteFX told me on my topic that he was using Swiftmail, so wanted to use it to, but i knew that it get's a little messy to setup and use it so i created this small library to help me Smile


You can assign variables and use them on your email files like so

email/welcome
Code:
Hello {user},

This is to check if it {variable}!


The library itself: https://gist.github.com/2190913


How to use:
Code:
$this->email->template('email/welcome');
$this->email->assign('user', 'John Doe');
$this->email->assign('variable', 'Works');
$this->email->from( array('[email protected]' => 'Your name') );
$this->email->to( array('[email protected]' => 'His name') );
if ( ! $this->email->send())
{
    show_error('Email not sended :c');
} else {
    echo('Email sended!');      
}


You need to create the file config/email.php and set the variables there
Code:
<?php

$config['protocol']  = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'your_password';
$config['charset']   = 'utf-8';
$config['mailtype']  = 'html';
$config['newline']   = "\r\n";



You need to edit the path to the Swiftmail installation on the top of the file Smile

Some ideas came from phpBB and from CodeIgniter !
#2

[eluser]InsiteFX[/eluser]
I would rename your library because it's the same as CodeIgniter's and may conflict with it!
#3

[eluser]Glazz[/eluser]
For what i need it doesn't conflict since it loads only this library not the CI one.
#4

[eluser]InsiteFX[/eluser]
Ok, but just pointing out you need to be careful with naming libraries.
#5

[eluser]Zaher Ghaibeh[/eluser]
hi,
have you consider trying swift-mailer spark library ? http://s.zah.me/GQnFvz
i didnt use it yet ( am planing to Big Grin ) ..




Theme © iAndrew 2016 - Forum software by © MyBB