Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function sendemail($qr, $user_id, $email){
- $count = count($qr);
- $countemail = count($email);
- // echo $countemail;
- for ($l=0; $l < $countemail; $l++) {
- $this->load->library('email');
- $this->email->clear(TRUE);
- $config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
- $config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
- $config['mailpath'] = '/usr/sbin/sendmail';
- $config['smtp_host'] = 'ssl://smtp.gmail.com';
- $config['smtp_auth'] = null; // Whether to use SMTP authentication, boolean TRUE/FALSE. If this option is omited or if it is NULL, then SMTP authentication is used when both $config['smtp_user'] and $config['smtp_pass'] are non-empty strings.
- $config['smtp_user'] = '9g.kiki@gmail.com';
- $config['smtp_pass'] = '';
- $config['smtp_port'] = 465;
- $config['smtp_timeout'] = 5; // (in seconds)
- $config['smtp_crypto'] = 'tls';
- // '' or 'tls' or 'ssl'
- $config['smtp_debug'] = 0; // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
- $config['debug_output'] = ''; // PHPMailer's SMTP debug output: 'html', 'echo', 'error_log' or user defined function with parameter $str and $level. NULL or '' means 'echo' on CLI, 'html' otherwise.
- $config['smtp_auto_tls'] = true; // Whether to enable TLS encryption automatically if a server supports it, even if `smtp_crypto` is not set to 'tls'.
- $config['smtp_conn_options'] = array(); // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.
- $config['wordwrap'] = true;
- $config['wrapchars'] = 76;
- $config['mailtype'] = 'html'; // 'text' or 'html'
- $config['charset'] = 'UTF-8'; // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
- $config['validate'] = true;
- $config['priority'] = 3; // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449
- $config['crlf'] = "\n"; // "\r\n" or "\n" or "\r"
- $config['newline'] = "\n"; // "\r\n" or "\n" or "\r"
- $config['bcc_batch_mode'] = false;
- $config['bcc_batch_size'] = 200;
- $config['encoding'] = '8bit';
- // $htmlContent = '<h1>Sending email via SMTP server</h1>';
- // $htmlContent .= '<p>This email has sent via SMTP server from CodeIgniter application</p>';
- //
- // $this->email->to('9g.amalia@gmail.com');
- // $this->email->from('9g.kiki@gmail.com','MyWebsite');
- // $this->email->subject('How to send email via SMTP server in CodeIgniter');
- // $this->email->message($htmlContent);
- // $this->email->from('9g.kiki@gmail.com')
- // ->reply_to('9g.kiki@gmail.com')
- // ->to('9g.amalia@gmail.com')
- // ->subject("Subject")
- // ->message("Your Message")
- // ->set_mailtype('html')
- // ->send();
- $this->email->initialize($config);
- // for ($i=0; $i < $count; $i++) {
- $a[$l] = base_url().'images/'.$qr[$l]['file_name'];
- print_r($a[$l]);
- $this->email->to($email[$l]);
- $this->email->from('9g.kiki@gmail.com','Marcom Test');
- // $a = base_url().'images/'.$qr;
- $this->email->attach($a[$l]);
- $this->email->subject('Invitation Test ');
- $this->email->message("
- <!DOCTYPE html>
- <html>
- <head>
- <meta name='viewport' content='width=device-width' />
- <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
- <title>INvitation</title>
- </head>
- <body bgcolor='#FFFFFF'>
- <h2>Hi, ".$user_id[$l]['name']."</h3>
- <br/>
- <h4 style='text-align:center;'> You are invited to Event</h4>
- <h4 style='text-align:center;'> Your Qr Code</h4>
- <br>
- </body>
- </html>
- ");
- if (!$this->email->send()) {
- // Raise error message
- show_error($this->email->print_debugger());
- } else {
- // Show success notification or other things here
- echo $this->email->print_debugger();
- echo 'Success to send email';
- }
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement