Advertisement
citstudio

Email Newsletter 4 : Email Content Helpers

Jun 23rd, 2014
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1.  
  2. function subscribe_finish($mail = 'default@domain.com', $name = 'Suhendra') {
  3.     $email_body = "Subscriber Finished <br/>Thank you.";
  4.  
  5.     $options["unsubscribe"] = FALSE;
  6.     $options["unsubscribe_link"] = "";
  7.  
  8.     $options["sender_email"] = "SenderEmail@domain.com";
  9.     $options["sender_name"] = "Sender Name";
  10.     $options["name"] = $name;
  11.     $options["destinations_email"] = $mail;
  12.     $options["email_subject"] = " Subscribe Finished";
  13.     $options["message"] = $email_body;
  14.     $options["template"] = "guest-book-template";
  15.  
  16.     return $options;
  17. }
  18.  
  19. function subscribe_verify_content($mail = 'default@domain.com', $code = '!@#$%^&*7654%^&*') {
  20.     $email_body = "Please verify your email address below.";
  21.     $email_body .= "<br/>";
  22.     $email_body .= '<a target="_blank" href="' . site_url("registration/subscribe") . '?mail-subscriber=' . $mail . '&activation-code=' . $code . '"><b>Verify ' . $mail . '</b></a>';
  23.     $email_body .= '<br/><em>if you can\'t see link above copy and paste URL in your browser below. </em>';
  24.     $email_body .= site_url("registration/subscribe") . '?mail-subscriber=' . $mail . '&activation-code=' . $code;
  25.  
  26.     $options["unsubscribe"] = FALSE;
  27.     $options["unsubscribe_link"] = "";
  28.  
  29.     $options["sender_email"] = "SenderEmail@domain.com";
  30.     $options["sender_name"] = "Sender Name";
  31.     $options["name"] = $mail;
  32.     $options["destinations_email"] = $mail;
  33.     $options["email_subject"] = " Subscribe Confirmation";
  34.     $options["message"] = $email_body;
  35.     $options["template"] = "guest-book-template";
  36.  
  37.     return $options;
  38. }
  39.  
  40. function sendmail($options = NULL) {
  41.     $ci = & get_instance();
  42.     $ci->load->library('email');
  43.  
  44.     $config['charset'] = 'utf-8';
  45.     $config['wordwrap'] = TRUE;
  46.     $config['mailtype'] = 'html';
  47.     $config['validate'] = TRUE;
  48.     $config['priority'] = 1;
  49.     $config['useragent'] = "MY Agent Mailer";
  50.     $config['protocol'] = "Email Protocol";
  51.     $config['smtp_host'] = "Email Host";
  52.     $config['smtp_user'] = "SMTP User as Sender Email";
  53.     $config['smtp_pass'] = "SMTP Password";
  54.     $config['smtp_port'] = "SMTP Port";
  55.  
  56.     $ci->email->initialize($config);
  57.  
  58.     $ci->email->set_newline("\r\n");
  59.  
  60.     $ci->email->from($options["sender_email"], $options["sender_name"]);
  61.     $ci->email->to($options["destinations_email"]);
  62.  
  63.     if (array_key_exists("cc_email", $options)) {
  64.         $ci->email->cc($options["cc_email"]);
  65.     }
  66.  
  67.     if (array_key_exists("bcc_email", $options)) {
  68.         $ci->email->cc($options["bcc_email"]);
  69.     }
  70.  
  71.     $ci->email->subject($options["email_subject"]);
  72.  
  73.     $template = "default";
  74.     $message = $options["message"];
  75.     $options["name"] = $options["name"];
  76.     $options["subject"] = "Thank you";
  77.  
  78.     if (array_key_exists("template", $options)) {
  79.         $template = $options["template"];
  80.         $message = $ci->load->view("path/to/email/layout/file" . $template, $options, TRUE);
  81.     }
  82.     $ci->email->message($message);
  83.  
  84.     if (!$ci->email->send()) {
  85.         $result = FALSE;
  86.     } else {
  87.         $result = TRUE;
  88.     }
  89.     return $result;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement