Reputation: 415
I created a function that will allow me to send emails using the Codeigniter email library class. This function can be used for when users sign up for my service or forgetting password emails sent to them or even for when I develop my PM module.
The below is the function I created. I have also included the call I make inside of the registration process function that handles creating the user and sending an email out to the user that registered with their information and welcoming them to the site.
What I am trying to understand is with the from method of the email class. Inside of the email class documentation it gives this:
$this->email->from()
Sets the email address and name of the person sending the email:
$this->email->from('[email protected]', 'Your Name');
What I would like to know is when I pass in the address for whom the email is to be sent out to have it include both parameters so that it has the email address and the companie's name or person's name being attached to the address.
I'm trying to make a call to my send_email function like this:
$this->general_functions->send_email($from_email_address, $post_email_address, $subject, $this->load->view('emails/'.$type.'-txt', $data, TRUE));
My function.
public function send_email($from_email_address, $to_email_address, $subject, $message)
{
$this->load->library('email');
$this->email->from($from_email_address);
$this->email->to($to_email_address);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
}
Upvotes: 0
Views: 59
Reputation: 415
What I've found out is that a lot of mail services block out emails that include a name sometimes so I have decided to omit that second parameter for the from method.
Upvotes: 1