View difference between Paste ID: w6P73P5D and YVkFnbtn
SHOW: | | - or go back to the newest paste.
1
public function sendemail($qr, $user_id, $email){
2
3
	  	$count = count($qr);
4-
      $this->load->library('email');
4+
5
	  	// echo $countemail;
6
	
7
8
9
	  	for ($l=0; $l < $countemail; $l++) { 
10
11
$this->load->library('email');
12
13
$this->email->clear(TRUE);
14-
      $config['smtp_crypto']      = 'tls';                       // '' or 'tls' or 'ssl'
14+
15
      $config['protocol']         = 'smtp';                   // 'mail', 'sendmail', or 'smtp'
16
      $config['mailpath']         = '/usr/sbin/sendmail';
17
      $config['smtp_host']        = 'ssl://smtp.gmail.com';
18
      $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.
19
      $config['smtp_user']        = '9g.kiki@gmail.com';
20
      $config['smtp_pass']        = '';
21
      $config['smtp_port']        = 465;
22
      $config['smtp_timeout']     = 5;                       // (in seconds)
23
      $config['smtp_crypto']      = 'tls';             
24
		
25
26
                // '' or 'tls' or 'ssl'
27
      $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.
28
      $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.
29
      $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'.
30
      $config['smtp_conn_options'] = array();                 // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.
31
      $config['wordwrap']         = true;
32
      $config['wrapchars']        = 76;
33
      $config['mailtype']         = 'html';                   // 'text' or 'html'
34
      $config['charset']          = 'UTF-8';                     // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
35
      $config['validate']         = true;
36
      $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
37
      $config['crlf']             = "\n";                     // "\r\n" or "\n" or "\r"
38
      $config['newline']          = "\n";                     // "\r\n" or "\n" or "\r"
39
      $config['bcc_batch_mode']   = false;
40
      $config['bcc_batch_size']   = 200;
41
      $config['encoding']         = '8bit';
42
43
44
    // $htmlContent = '<h1>Sending email via SMTP server</h1>';
45
    // $htmlContent .= '<p>This email has sent via SMTP server from CodeIgniter application</p>';
46
    //
47
    // $this->email->to('9g.amalia@gmail.com');
48
    // $this->email->from('9g.kiki@gmail.com','MyWebsite');
49
    // $this->email->subject('How to send email via SMTP server in CodeIgniter');
50
    // $this->email->message($htmlContent);
51
52
53
	  // $this->email->from('9g.kiki@gmail.com')
54
	  //      ->reply_to('9g.kiki@gmail.com')
55
	  //      ->to('9g.amalia@gmail.com')
56
	  //      ->subject("Subject")
57
	  //      ->message("Your Message")
58
	  //      ->set_mailtype('html')
59
	  //      ->send();
60
	  $this->email->initialize($config);
61
				// for ($i=0; $i < $count; $i++) { 
62
					$a[$l] = base_url().'images/'.$qr[$l]['file_name'];
63
64
					print_r($a[$l]);
65
66
				  $this->email->to($email[$l]);
67
				  $this->email->from('9g.kiki@gmail.com','Marcom Test');
68
				  // $a = base_url().'images/'.$qr;
69
				  $this->email->attach($a[$l]);
70
				  $this->email->subject('Invitation Test ');
71
				  $this->email->message("
72
					  <!DOCTYPE html>
73
					    <html>
74
					    <head>
75
					    <meta name='viewport' content='width=device-width' />
76
					    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
77
					    <title>INvitation</title>
78
79
80
					  </head>
81
82
					  <body bgcolor='#FFFFFF'>
83
84
					  <h2>Hi, ".$user_id[$l]['name']."</h3>
85
					  <br/>
86
					  <h4 style='text-align:center;'> You are invited to Event</h4>
87
					  <h4 style='text-align:center;'> Your Qr Code</h4>
88
					  
89
					  <br>
90
91
92
					  </body>
93
94
					  </html>
95
					  ");
96
			    if (!$this->email->send()) {
97
			          // Raise error message
98
			          show_error($this->email->print_debugger());
99
			      } else {
100
			          // Show success notification or other things here
101
			          echo $this->email->print_debugger();
102
			          echo 'Success to send email';
103
			      }
104
			// }
105
		}
106
107
108
    }