syedanam
7/25/2017 - 5:22 PM

Codeigniter Send Email

Codeigniter Send Email

$route['send-mail'] = 'welcome/send_mail';
<form action="<?php echo base_url() ?>send-mail" method="post" accept-charset="utf-8">
	<table>		
		
			<tr>
				<td>mail address</td>
				<td><input type="text" name="email"></td>
			</tr>
			<tr>
				<td>title</td>
				<td><input type="text" name="title"></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="submit" name="send"></td>
			</tr>		
	</table>

</form>
public function send_mail(){

		$this->load->library('email');

		$this->email->initialize(array(
			'protocol' => 'smtp',
			'smtp_host' => 'smtp.mailtrap.io',
			'smtp_user' => '768fb9ee7304fa',
			'smtp_pass' => 'b272629bc279af',
			'smtp_port' => 2525,
			'crlf' => "\r\n",
			'newline' => "\r\n"
			));

		$email_from = "syed.anam@ymail.com";
		$email_to = $this->input->post('email', true);
		$title = $this->input->post('title', true);
		

		$this->email->from($email_from, 'Nourin');
		$this->email->to($email_to);
		// $this->email->cc('another@another-example.com');
		// $this->email->bcc('them@their-example.com');
		$this->email->subject($title);
		$this->email->message('Testing the email class.');
		$this->email->send();

		echo $this->email->print_debugger();
	}