Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]Problem sending email
#1

[eluser]bondjp[/eluser]
Hi, how can i send 2 emails to 2 different users with 2 different messages?
I can send one email without any problem but i'm not seeing how can i send a second email to another person with another message.
Thanks.

Here's my code for one email:
Code:
$config['protocol'] = 'mail';
$this->email->initialize($config);
$this->email->from('[email protected]', 'My site');
$this->email->to($data['email']);
$this->email->subject('Subject');
$this->email->message($this->load->view('email/confirmed-html', $data, TRUE));
$this->email->send();
#2

[eluser]Ben Edmunds[/eluser]
Just change your $data array and reference those variables in your view.

Really not sure I see the problem?
#3

[eluser]bondjp[/eluser]
I'm using this in my controller.
When something happens i send 2 emails to 2 different users with 2 different messages(views).

Using the example i put how can i send at the same time a second email to :$this->email->to($data['secemail']); with subject: "Subject Second Email" and with message: $this->load->view('email/secondconfirmed-html' ?
Thanks.
#4

[eluser]Ben Edmunds[/eluser]
You code do:

Code:
$this->email->from('[email protected]', 'My site');
$this->email->to($data['email1']);
$this->email->subject('Subject');
$this->email->message($this->load->view('email/confirmed-html1', $data, TRUE));
$this->email->send();

$this->email->from('[email protected]', 'My site');
$this->email->to($data['email2']);
$this->email->subject('Subject');
$this->email->message($this->load->view('email/confirmed-html2', $data, TRUE));
$this->email->send();

Or you could put it into a loop and use variables.

How new are you to PHP? Do you understand looping and variables? Don't take offense, just trying to see what level you are on...
#5

[eluser]bondjp[/eluser]
[quote author="Ben Edmunds" date="1269248973"]You code do:

Code:
$this->email->from('[email protected]', 'My site');
$this->email->to($data['email1']);
$this->email->subject('Subject');
$this->email->message($this->load->view('email/confirmed-html1', $data, TRUE));
$this->email->send();

$this->email->from('[email protected]', 'My site');
$this->email->to($data['email2']);
$this->email->subject('Subject');
$this->email->message($this->load->view('email/confirmed-html2', $data, TRUE));
$this->email->send();

Or you could put it into a loop and use variables.

How new are you to PHP? Do you understand looping and variables? Don't take offense, just trying to see what level you are on...[/quote]

I tried that but it sends both emails to the second user...
I'm new to php and i know what loops and variables are.
Thanks
#6

[eluser]Ben Edmunds[/eluser]
Post the code you used including the variable declarations.

Thanks,
#7

[eluser]bondjp[/eluser]
Nevermind, it works like you posted.
I just can't believe i had the same email on both users... :red:
Sorry for waisting your time.




Theme © iAndrew 2016 - Forum software by © MyBB