本文整理汇总了PHP中Email::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::send方法的具体用法?PHP Email::send怎么用?PHP Email::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dosave
/**
* Form action handler for ContactInquiryForm.
*
* @param array $data The form request data submitted
* @param Form $form The {@link Form} this was submitted on
*/
function dosave(array $data, Form $form, SS_HTTPRequest $request)
{
$SQLData = Convert::raw2sql($data);
$attrs = $form->getAttributes();
if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
// most probably spam - terminate silently
Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
return;
}
$item = new ContactInquiry();
$form->saveInto($item);
// $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
$item->write();
$mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
$mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
$mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
$email = new Email($mailFrom, $mailTo, $mailSubject);
$email->replyTo($SQLData['Email']);
$email->setTemplate("ContactInquiry");
$email->populateTemplate($SQLData);
$email->send();
// $this->controller->redirectBack();
if ($email->send()) {
$this->controller->redirect($this->controller->Link() . "success");
} else {
$this->controller->redirect($this->controller->Link() . "error");
}
return false;
}
示例2: send
/**
* Send the email
*
* @return void
*/
public function send()
{
if ($this->enabled) {
if (!$this->emailer->send()) {
$this->logger->addWarning($this->emailer->error());
}
} else {
$this->logger->addWarning('Faked sending an email ' . $this->emailer->get('body'));
}
}
示例3: action_email
public function action_email()
{
if (count($this->request->post())) {
$hostname = $this->request->post('email_hostname');
$port = $this->request->post('email_port');
$username = $this->request->post('email_username');
$password = $this->request->post('email_password');
$encryption = $this->request->post('email_encryption');
$email_address = $this->request->post('email_address');
try {
$config = $this->_create_email_config($hostname, $port, $username, $password, $encryption);
// email_address
if (strlen($email_address)) {
try {
Email::connect($config);
Email::send($email_address, $email_address, "Beans Email Verification", "You can ignore this email - it was a self-generated message " . "used to verify your email server credentials.", FALSE);
} catch (Exception $e) {
return $this->_view->send_error_message("An error occurred when verifying your email settings: " . $e->getMessage());
}
}
Session::instance('native')->set('config_email', $config);
$this->request->redirect('/install/auth');
} catch (Exception $e) {
$this->_view->send_error_message($e->getMessage());
}
}
}
示例4: changeStatus
public function changeStatus()
{
$status = (int) $this->request->get('status');
$shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress'));
$shipment->loadItems();
$zone = $shipment->getDeliveryZone();
$shipmentRates = $zone->getShippingRates($shipment);
$shipment->setAvailableRates($shipmentRates);
$history = new OrderHistory($shipment->order->get(), $this->user);
$shipment->status->set($status);
$shipment->save();
$history->saveLog();
$status = $shipment->status->get();
$enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES');
$m = array('EMAIL_STATUS_UPDATE_NEW' => Shipment::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => Shipment::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => Shipment::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => Shipment::STATUS_SHIPPED);
$sendEmail = false;
foreach ($m as $configKey => $constValue) {
if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) {
$sendEmail = true;
}
}
if ($sendEmail || $this->config->get('EMAIL_STATUS_UPDATE')) {
$user = $shipment->order->get()->user->get();
$user->load();
$email = new Email($this->application);
$email->setUser($user);
$email->setTemplate('order.status');
$email->set('order', $shipment->order->get()->toArray(array('payments' => true)));
$email->set('shipments', array($shipment->toArray()));
$email->send();
}
return new JSONResponse(false, 'success');
}
示例5: validateStep
/**
* This does not actually perform any validation, but just creates the
* initial registration object.
*/
public function validateStep($data, $form)
{
$form = $this->getForm();
$datetime = $form->getController()->getDateTime();
$confirmation = $datetime->Event()->RegEmailConfirm;
$registration = $this->getForm()->getSession()->getRegistration();
// If we require email validation for free registrations, then send
// out the email and mark the registration. Otherwise immediately
// mark it as valid.
if ($confirmation) {
$email = new Email();
$config = SiteConfig::current_site_config();
$registration->TimeID = $datetime->ID;
$registration->Status = 'Unconfirmed';
$registration->write();
if (Member::currentUserID()) {
$details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email);
} else {
$details = $form->getSavedStepByClass('EventRegisterTicketsStep');
$details = $details->loadData();
}
$link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token);
$regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token);
$email->setTo($details['Email']);
$email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title));
$email->setTemplate('EventRegistrationConfirmationEmail');
$email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link)));
$email->send();
Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage);
} else {
$registration->Status = 'Valid';
$registration->write();
}
return true;
}
示例6: send_message
/**
* make sure to return TRUE as response if the message is sent
* successfully
* Sends a message from the current user to someone else in the networkd
* @param Int | String | Member $to -
* @param String $message - Message you are sending
* @param String $link - Link to send with message - NOT USED IN EMAIL
* @param Array - other variables that we include
* @return Boolean - return TRUE as success
*/
public static function send_message($to, $message, $link = "", $otherVariables = array())
{
//FROM
if (!empty($otherVariables["From"])) {
$from = $otherVariables["From"];
} else {
$from = Email::getAdminEmail();
}
//TO
if ($to instanceof Member) {
$to = $to->Email;
}
//SUBJECT
if (!empty($otherVariables["Subject"])) {
$subject = $otherVariables["Subject"];
} else {
$subject = substr($message, 0, 30);
}
//BODY
$body = $message;
//CC
if (!empty($otherVariables["CC"])) {
$cc = $otherVariables["CC"];
} else {
$cc = "";
}
//BCC
$bcc = Email::getAdminEmail();
//SEND EMAIL
$email = new Email($from, $to, $subject, $body, $bounceHandlerURL = null, $cc, $bcc);
return $email->send();
}
示例7: action_index
function action_index()
{
if ($_POST) {
$feedback = ORM::factory('feedback');
try {
$feedback->values($_POST, array('title', 'text'));
$feedback->type = 1;
$feedback->user_id = $this->user->id;
$feedback->date = Date::formatted_time();
$feedback->save();
$email_view = View::factory('email/feedback')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text)->render();
Email::send('sekretar@as-avtoservice.ru', array('no-reply@as-avtoservice.ru', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE);
Message::clear();
Message::set(Message::SUCCESS, 'Спасибо! Ваше сообщение отправлено администрации сайта');
$this->request->redirect('cabinet');
} catch (ORM_Validation_Exception $e) {
Message::set(Message::ERROR, 'Произошла ошибка при отправке сообщения');
$this->errors = $e->errors('models');
$this->values = $_POST;
}
}
$this->view = View::factory('frontend/cabinet/feedback/create_feedback')->set('errors', $this->errors)->set('values', $this->values);
$this->template->title = 'Обратная связь';
$this->template->content = $this->view;
}
示例8: action_index
public function action_index()
{
$view = View::factory('forgot_password');
$this->template->content = $view->render();
if ($this->request->method() === Request::POST) {
$email = $this->request->post('email');
$user = new Model_User();
$password_recovery = new Model_Password_Recovery();
$unique_email = $user->unique_email($email);
if ($unique_email === true) {
throw new Exception("Email is not correct!");
}
$view_for_message = View::factory('forgot_password/send_email');
$user_id = $user->get_id($email);
$hash = sha1(Security::token());
$view_for_message->user_id = $user_id;
$view_for_message->hash = $hash;
$create_attemp = $password_recovery->create_attemp($email, $user_id, $hash);
if (!$create_attemp) {
throw new Exception("Cannot create attemp!");
}
Email::connect();
$to = array($email);
$from = array('user@localhost', 'admin');
$subject = 'Password recovery';
$message = $view_for_message->render();
$send_email = Email::send($to, $from, $subject, $message, true);
if (!$send_email) {
throw new Exception("Cannot send email! \n {$send_email}");
}
$this->redirect('/');
}
}
示例9: sendEmail
public function sendEmail($emailbody, $time, $value, $options)
{
global $user, $session;
$timeformated = DateTime::createFromFormat("U", (int) $time);
$timeformated->setTimezone(new DateTimeZone($this->parentProcessModel->timezone));
$timeformated = $timeformated->format("Y-m-d H:i:s");
$tag = array("{id}", "{type}", "{time}", "{value}");
$replace = array($options['sourceid'], $options['sourcetype'], $timeformated, $value);
$emailbody = str_replace($tag, $replace, $emailbody);
if ($options['sourcetype'] == "INPUT") {
$inputdetails = $this->parentProcessModel->input->get_details($options['sourceid']);
$tag = array("{key}", "{name}", "{node}");
$replace = array($inputdetails['name'], $inputdetails['description'], $inputdetails['nodeid']);
$emailbody = str_replace($tag, $replace, $emailbody);
} else {
if ($options['sourcetype'] == "VIRTUALFEED") {
// Not suported for VIRTUAL FEEDS
}
}
$emailto = $user->get_email($session['userid']);
require_once "Lib/email.php";
$email = new Email();
//$email->from(from);
$email->to($emailto);
$email->subject('Emoncms event alert');
$email->body($emailbody);
$result = $email->send();
if (!$result['success']) {
$this->log->error("Email send returned error. message='" . $result['message'] . "'");
} else {
$this->log->info("Email sent to {$emailto}");
}
}
示例10: addUser
public function addUser($data)
{
$vData = $data;
$validation = Validation::factory($vData);
$validation->rule('username', 'not_empty');
$validation->rule('username', 'email');
if (!$validation->check()) {
$this->errors = $validation->errors('userErrors');
return FALSE;
}
$pass = Arr::get($data, 'pass');
$username = addslashes(Arr::get($data, 'username'));
$myuser = ORM::factory('Myuser');
$auth = Auth::instance();
$pass = $auth->hash($pass);
//Создаем пользователя
$myuser->username = $username;
$myuser->email = $username;
$myuser->password = $pass;
$myuser->name = addslashes(Arr::get($data, 'name'));
$myuser->phone = addslashes(Arr::get($data, 'phone'));
try {
$myuser->save();
//Узнаем id пользователя
$add_user_id = ORM::factory("user", array("username" => $username))->id;
$token = substr($auth->hash($add_user_id . $username), 0, 20);
//добавляем роль пользователя
$model_addrole = new Model_Addrole();
$model_addrole->user_id = $add_user_id;
$model_addrole->role_id = Arr::get($data, "role");
$model_addrole->save();
//добавляем запись для активации
$model_addtoken = new Model_Addtoken();
$model_addtoken->user_id = $add_user_id;
$model_addtoken->token = $token;
$model_addtoken->save();
//отправляем пользователю сообщение для авторизации
$config = Kohana::$config->load('email');
$mbase = new Model_Base();
$options = $mbase->getOptions();
Email::connect($config);
$to = $username;
$subject = 'Добро пожаловать на сайт ' . $options['sitename'];
$from = $config['options']['username'];
$message = '<b>Отправитель</b>: ' . Kohana::$base_url . '<br>';
$message .= 'Для работы с заказами на сайте Вам необходимо активировать учетную запись. <br>
<br>
Ваш логин: ' . $username . '<br>
Ваш пароль: ' . Arr::get($data, 'pass') . '<br><br>
Для активации перейдите по <a href="' . Kohana::$base_url . 'registration?token=' . $token . '&user=' . $username . '">этой ссылке</a>
<hr>
Спасибо за то, что пользуетесь услугами нашего сайта. По всем вопросам обращайтесь в техподдержку: ' . $config['options']['username'];
$res = Email::send($to, $from, $subject, $message, $html = TRUE);
return $add_user_id;
} catch (ORM_Validation_Exception $e) {
$this->errors = $e->errors('validation');
return false;
}
}
示例11: send
/**
* @see parent::send()
*/
public function send()
{
if (!empty($_FILES['file']['tmp_name'])) {
$this->attach($_FILES['file']['tmp_name'], $_FILES['file']['name']);
}
return parent::send();
}
示例12: action_index
function action_index()
{
$services[0] = 'Выбрать компанию';
foreach ($this->user->services->find_all() as $service) {
$services[$service->id] = $service->name;
}
if ($_POST) {
$feedback = ORM::factory('feedback');
try {
$feedback->values($_POST, array('title', 'text'));
$feedback->type = 2;
$feedback->user_id = $this->user->id;
$feedback->service_id = Arr::get($_POST, 'service_id', 0);
$feedback->date = Date::formatted_time();
$feedback->save();
$email_view = View::factory('email/adv')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text);
if ($feedback->service_id != 0) {
$email_view->set('service', $this->user->services->where('id', '=', $feedback->service_id)->find());
}
$email_view->render();
Email::send('sekretar@as-avtoservice.ru', array('no-reply@as-avtoservice.ru', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE);
Message::set(Message::SUCCESS, 'Спасибо! Ваше заявка принята на рассмотрение администрацией сайта');
$this->request->redirect('cabinet');
} catch (ORM_Validation_Exception $e) {
$this->errors = $e->errors('models');
$this->values = $_POST;
}
}
$this->view = View::factory('frontend/cabinet/adv/create_blank')->set('services', $services)->set('errors', $this->errors)->set('values', $this->values);
$this->template->title = 'Реклама на сайте';
$this->template->bc['#'] = $this->template->title;
$this->template->content = $this->view;
}
示例13: action_ajax_add_feedback
public function action_ajax_add_feedback()
{
if ($_POST) {
$errors = array('name' => 'false', 'text' => 'false', 'email' => 'false', 'check' => 'false', 'phone' => 'false');
if (Validation::factory($_POST)->rule('email', 'email')->rule('email', 'not_empty')->check()) {
$errors['email'] = 'true';
}
if (Validation::factory($_POST)->rule('phone', 'not_empty')->check()) {
$errors['phone'] = 'true';
}
if (Validation::factory($_POST)->rule('name', 'not_empty')->check()) {
$errors['name'] = 'true';
}
if (Validation::factory($_POST)->rule('text', 'not_empty')->check()) {
$errors['text'] = 'true';
}
$check = arr::get($_POST, 'check');
if (!$check) {
$errors['check'] = 'true';
}
if ($errors['name'] == 'true' && $errors['email'] == 'true' && $errors['phone'] == 'true' && $errors['text'] == 'true' && $errors['check'] == 'true') {
$feedback = ORM::factory('Feedback');
$feedback->name = arr::get($_POST, 'name');
$feedback->phone = arr::get($_POST, 'phone');
$feedback->email = arr::get($_POST, 'email');
$feedback->text = arr::get($_POST, 'text');
$feedback->save();
Email::send('info@trip-shop.by', array('info@trip-shop.by', 'Trip-Shop'), 'Новый отзыв', 'Имя - ' . arr::get($_POST, 'name') . '<br/>' . 'Email - ' . arr::get($_POST, 'email') . '<br/>' . 'Телефон - ' . arr::get($_POST, 'phone') . '<br/>' . arr::get($_POST, 'text'), true);
}
echo json_encode($errors);
} else {
$this->forward_404();
}
}
示例14: sendStandardEmail
/**
* @param $from (Domain)
* @param $to (Email)
* @param $subject
* @param $message
* @return boolean True or False
*/
public static function sendStandardEmail($from, $to, $subject, $message)
{
$headers = "From: no-reply@{$from} \r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=UTF-8\r\n";
$message = '<html>
<head></head>
<body style="background: #f4f3f1; margin: 0px; padding: 0px;">
<table style="margin: 20px auto; width: 880px; background: #fff; border: 1px #dfdfdf solid; padding: 10px;">
<tr>
<td>
<a target="_blank" href="//' . $from . '" style="width: 131px; height: 44px; margin: 6px 0px 6px 0px; float: left;">
<img src ="//' . $from . '/images/logo.png"/>
</a>
</td>
</tr>
<tr>
<td>
<h1 style="color: #ff7346; font-weight: normal; margin: 5px 10px; font-size: 15pt; font-family: arial;">' . $subject . '</h1>
</td>
</tr>
<tr>
<td>
<div style="margin: 5px 10px; font-family: arial; color: #3d3d3d;">' . $message . '</div>
</td>
</tr>
</table>
</body>
</html>';
return Email::send($to, $subject, $message, $headers);
}
示例15: form
public function form(SS_HTTPRequest $request)
{
/*
echo "<pre>";
echo print_r($request);
echo "<hr>";
echo print_r($_POST);
echo "</pre>";
echo $_SERVER['HTTP_REFERER'];
*/
$data = $_POST;
$email = new Email();
$email->setTo('mail@nobrainer.dk');
$email->setFrom($data['Email']);
$email->setSubject("Contact Message from " . $data["Name"]);
$messageBody = "\n\t\t\t<p><strong>Name:</strong> {$data['Name']}</p>\n\t\t\t<p><strong>Message:</strong> {$data['Message']}</p>\n\t\t";
$email->setBody($messageBody);
$email->send();
/* return array(
'Content' => '<p>Thank you for your feedback.</p>',
'Form' => ''
);
*/
$this->redirect($_SERVER['HTTP_REFERER'] . "?status=success");
}