Seme Email Library

The Seme_Email library purpose is for sending email from Seme Framework. Seme Email has HTML email template for dynamic content of html.


How to use

First we have to loaded library by using library loaded:

$this->lib('seme_email');

You can put libary loader in constructor of controller or on each method in your controller.

Basic Usage

Seme Email has some method, here is the list of common methods:

Class Product extends SEME_Controller{
  public function __construct(){
    $this->lib('seme_log');
  }
  public function index(){
    $replacer = array();
    $replacer['site_name'] = $this->site_name;
    $replacer['nama'] = $nama;
    $replacer['activation_link'] = $link;
    $this->seme_email->flush(); //optional
    $this->seme_email->replyto($this->site_name,$this->site_replyto);
    $this->seme_email->from($this->site_email,$this->site_name);
    $this->seme_email->subject('Registration Successful');
    $this->seme_email->to($email,$nama);
    $this->seme_email->template('account_register');
    $this->seme_email->replacer($replacer);
    $this->seme_email->send();
  }
}

Seme Email has several methods that can used for sending email properly.

From Method

This method mandatory for declare origin of email. Required two parameter, first parameter is email and the second parameter is name of sender.

Subject Method

This method mandatory for declare title of email. Required one parameter contained about your summary.

To Method

This method mandatory for declare target of email. Required two parameter, first parameter is email and the second parameter is name of sender. Can be called more than once for sending multiple email address.

Template Method

This method only required if you one to create html formatted email. Default location about this file is in kero/lib/seme_email/template/. You can replace the string with "replacer" for creating dynamic email. Here is the example:

<html>
<body>
<p>Hi ,</p>
<p>Thank you for using seme framework</p>
</body>
</html>

On HTML script above, we can see the code. You can replace this string with real name through the script.

Replacer Method

This method allow replacing string on email template with coding. Here is the example:

$replacer = array();
$replacer['first_name'] = 'Agus Setiawan';
$this->seme_email->replacer($replacer);

If this example combined with email template above, you can send email with replaced by Agus Setiawan.

Flush method

Use this method for clearing assigned properties used before.

Special Notes

Please makes more attention if you want to send email by following community guidance for email usage. If your email always sent to spam, you have to use real domain and real working email.

Google has completed guide for email usage. Here is the quick explanation:

  • Always put Subject on email.
  • Body or main content email consist of greetings, main content, and footer.
  • Avoid attachment.
  • For default purpose always use noreply@example.com, adjust example.com to your domain.
  • For money related email content use finance@example.com and makes sure the email is active.
  • For marketing purpose please use real name of marketing such as adry@example.com and makes sure the email is active can be replied.