· 8 years ago · Mar 15, 2018, 12:24 PM
1public function notify_marketing(){
2 $config = Array(
3 'protocol' => 'smtp',
4 'smtp_host' => 'ssl://smtp.googlemail.com',
5 'smtp_port' => 465,
6 'smtp_user' => 'myvalidemail@gmail.com',
7 'smtp_pass' => '*******',//my valid email password
8 'mailtype' => 'html',
9 'charset' => 'iso-8859-1',
10 'wordwrap' => TRUE
11 );
12
13 $this->email->initialize($config);
14 $this->load->library('email', $config);
15 $this->email->set_newline("rn");
16 $this->email->from('myvalidemail@gmail.com');
17 $this->email->to('validreceiptent@gmail.com');
18 $this->email->subject('My Subject');
19 $this->email->message('Hello there');
20 if($this->email->send())
21 {
22 $this->session->set_flashdata("success","Email sent.");
23 }
24 else
25 {
26 show_error($this->email->print_debugger());
27 }
28}
29
30<div id="exception_error">
31 <h1><span class="type">An Error Was Encountered [ 500 ]</span></h1>
32 <div class="content">
33 <p><p>220 smtp.googlemail.com ESMTP bv4sm16669443pbb.86 - gsmtp
34<br /><pre>hello: 250-smtp.googlemail.com at your service, [110.44.127.179]
35250-SIZE 35882577
36250-8BITMIME
37250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH
38250-ENHANCEDSTATUSCODES
39250-PIPELINING
40250-CHUNKING
41250 SMTPUTF8
42</pre>lang:email_smtp_auth_pw<br />lang:email_send_failure_smtp<br /><pre>User-Agent: CodeIgniter
43Date: Tue, 18 Aug 2015 12:03:42 +0545
44From: <********@gmail.com>
45Return-Path: <********@gmail.com>
46To: *******@gmail.com
47Subject: =?iso-8859-1?Q?My_Subject?=
48Reply-To: "********@gmail.com" <*********@gmail.com>
49X-Sender: *******@gmail.com
50X-Mailer: CodeIgniter
51X-Priority: 3 (Normal)
52Message-ID: <55d2ce42747f5@gmail.com>
53Mime-Version: 1.0
54
55<?php
56 $config['protocol'] = 'smtp';
57 $config['smtp_host'] = 'ssl://smtp.gmail.com'; //change this
58 $config['smtp_port'] = '465';
59 $config['smtp_user'] = 'user@gmail.com'; //change this
60 $config['smtp_pass'] = 'password'; //change this
61 $config['mailtype'] = 'html';
62 $config['charset'] = 'iso-8859-1';
63 $config['wordwrap'] = TRUE;
64 $config['newline'] = "rn";
65?>
66
67<?php
68//send mail
69function sendmail()
70{
71 $this->load->library('email'); // load email library
72 $this->email->from('user@gmail.com', 'sender name');
73 $this->email->to('test1@gmail.com');
74 $this->email->cc('test2@gmail.com');
75 $this->email->subject('Your Subject');
76 $this->email->message('Your Message');
77 $this->email->attach('/path/to/file1.png'); // attach file
78 $this->email->attach('/path/to/file2.pdf');
79 if ($this->email->send())
80 echo "Mail Sent!";
81 else
82 echo "There is error in sending mail!";
83}
84?>