Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'ssl://smtp.google.com',
- 'smtp_port' => 465,
- 'smtp_user' => 'sender@gmail.com',
- 'smtp_pass' => 'password'
- );
- $this->load->library('email',$config);
- $this->email->set_newline("rn");
- $this->email->from("sender@gmail.com");
- $this->email->to("receiver@gmail.com");
- $this->email->subject("Email with Codeigniter");
- $this->email->message("This is email has been sent with Codeigniter");
- if($this->email->send())
- {
- echo "Your email was sent.!";
- } else {
- show_error($this->email->print_debugger());
- }
- public function send_mail()
- {
- require_once(APPPATH.'third_party/PHPMailer-master/PHPMailerAutoload.php');
- $mail = new PHPMailer();
- $mail->IsSMTP(); // we are going to use SMTP
- $mail->SMTPAuth = true; // enabled SMTP authentication
- $mail->SMTPSecure = "ssl"; // prefix for secure protocol to connect to the server
- $mail->Host = "smtp.gmail.com"; // setting GMail as our SMTP server
- $mail->Port = 465; // SMTP port to connect to GMail
- $mail->Username = "mail@gmail.com"; // user email address
- $mail->Password = "password"; // password in GMail
- $mail->SetFrom('mail@gmail.com', 'Mail'); //Who is sending
- $mail->isHTML(true);
- $mail->Subject = "Mail Subject";
- $mail->Body = '
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <h3>Heading</h3>
- <p>Message Body</p><br>
- <p>With Regards</p>
- <p>Your Name</p>
- </body>
- </html>
- ';
- $destino = receiver@gmail.com; // Who is addressed the email to
- $mail->AddAddress($destino, "Receiver");
- if(!$mail->Send()) {
- return false;
- } else {
- return true;
- }
- }
- 'smtp_host' => 'ssl://smtp.googlemail.com',
Add Comment
Please, Sign In to add comment