A
A
Anton2015-11-30 08:03:18
HTML
Anton, 2015-11-30 08:03:18

Sending an order from the basket to two mails, how to do it?

Hello, I'm trying to send an order from the basket to two mails, one mail is taken from the site settings with settings from the table, and I want to register the other manually.
But not how it doesn't work.

$this->session->delete('tovary');
$settings = ORM::factory('setting')->find();

// отправляем сообщение на email
$config = Kohana::$config->load('email');
Email::connect($config);
//получатель
$to = "[email protected]";
// заголовок письма
$subject = "Новый заказ с сайта ".$url."";
// отправитель
$from = '[email protected]';
// само письмо в html
$message = "" . $table;

$full = ($total['total'] + $pm->cost + $del->cost);
$emails = explode(",", $settings->emails);

$this->action_send_messsge(trim($data['phone']), $full, $inv_id);

if (is_array($emails) AND $settings->send_order) {
foreach ($emails as $email) {
if (!empty($email)) {
$email = trim($email);

// код который отправляет, рабочий							
Email::send($email, $from, $to, $subject, true);
              
echo $table;
if ($pm->is_robo == 1) {
$link = Chronopay::factory();
$this->request->redirect($link->get_link($full, $inv_id));
} elseif ($pm->id == 3) {
$this->request->redirect("/cart/bank/$inv_id/$full");
}
}
}
} else {
if ($settings->send_order) {
//mail($user->email,$subject,$message,$to);
}
}
}
$this->request->redirect("/cart/done");
} else {
$this->request->redirect("/");
}

}

I added the recipient's to field, but his email is not taken, it is taken and inserted directly into the letter where the text about the order and the product.
Right now it works like this, the order goes to the admin on the email that is taken from the site settings.
$settings->send_order
I also want to make the customer send a letter to the mail, his data is here $users->mail
But I can’t add the code, I tried to do it, it didn’t work out.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton, 2015-11-30
Websaytovsky @ws17

I understood the essence of the work a little, added
$sender = explode(",", $orders->sender);
also added to the $sender field
in this field
Email::send($email, $sender, $from, $subject, $message, true);
When ordering, an error occurs, if you remove one of $email, $sender, then everything works, that is, it does not want to leave for two mails. how to be I do not know.
The error is like this:
8dc4f4e7c37643a9b632c5602f00c988.jpg

D
Dmitry Bay, 2015-11-30
@kawabanga

set up a redirect from the main mail. it is much more efficient for you in this case.

G
Grigory Vasilkov, 2015-12-08
@gzhegow

You, my friend, have nothing in the From array by the time the command is executed, as we can see.
Perhaps you are looking for a problem in the script, but it is not in this file at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question