本文整理汇总了PHP中Email类的典型用法代码示例。如果您正苦于以下问题:PHP Email类的具体用法?PHP Email怎么用?PHP Email使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Email类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateRequest
public function updateRequest($data)
{
$req = $this->find($data['id']);
if ($data['action'] == 'y') {
$ts3 = new TsAPI();
// send TS3 create request
$token = $ts3->createChan($req->cname);
if ($token) {
$req->reason = htmlspecialchars($data['msg']);
$req->status = 1;
$req->save();
if ($data['email']) {
$email = new Email();
$email->sendYes(array('req' => $req, 'token' => $token));
}
return 1;
}
} elseif ($data['action'] == 'n') {
$req->reason = htmlspecialchars($data['msg']);
$req->status = 2;
$req->save();
if ($data['email']) {
$email = new Email();
$email->sendNo(array('req' => $req));
}
return 2;
}
}
示例2: onBeforeWrite
public function onBeforeWrite()
{
if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) {
$discussion = Discussion::get()->byID($this->owner->ParentID);
$discussion_author = $discussion->Author();
$holder = $discussion->Parent();
$author = Member::get()->byID($this->owner->AuthorID);
// Get our default email from address
if (DiscussionHolder::config()->send_emails_from) {
$from = DiscussionHolder::config()->send_email_from;
} else {
$from = Email::config()->admin_email;
}
// Vars for the emails
$vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder"));
// Send email to discussion owner
if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) {
$subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname));
$email = new Email($from, $discussion_author->Email, $subject);
$email->setTemplate('NewCreatedReplyEmail');
$email->populateTemplate($vars);
$email->send();
}
// Send to anyone who liked this, if they want notifications
foreach ($discussion->LikedBy() as $liked) {
if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) {
$subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname));
$email = new Email($from, $liked->Email, $subject);
$email->setTemplate('NewLikedReplyEmail');
$email->populateTemplate($vars);
$email->send();
}
}
}
}
示例3: it_is_a_correct_object
/** @test */
public function it_is_a_correct_object()
{
$field = new Email('test', 'Test');
$this->assertSame('email', $field->getOption('type'));
$this->assertSame('administr/form::text', $field->getView());
$this->assertInstanceOf(AbstractType::class, $field);
}
示例4: 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();
}
示例5: sendReminderMail
/**
* Sends a reminder mail to definined member groups.
*/
public function sendReminderMail()
{
// first check if required extension 'associategroups' is installed
if (!in_array('associategroups', $this->Config->getActiveModules())) {
$this->log('RscNewsletterReminder: Extension "associategroups" is required!', 'RscNewsletterReminder sendReminderMail()', TL_ERROR);
return false;
}
$this->loadLanguageFile("tl_settings");
if ($this->timeleadReached()) {
$objEmail = new \Email();
$objEmail->logFile = 'RscNewsletterReminderEmail.log';
$objEmail->from = $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderAddress'];
$objEmail->fromName = strlen($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName']) > 0 ? $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName'] : $GLOBALS['TL_CONFIG']['websiteTitle'];
$objEmail->subject = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSubject']);
$objEmail->html = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailContent']);
$objEmail->text = $this->transformEmailHtmlToText($objEmail->html);
try {
$objEmail->sendTo($this->getReceiverEmails());
$this->log('Monthly sending newsletter reminder finished successfully.', 'RscNewsletterReminder sendReminderMail()', TL_CRON);
return true;
} catch (Swift_RfcComplianceException $e) {
$this->log("Mail could not be send: " . $e->getMessage(), "RscNewsletterReminder sendReminderMail()", TL_ERROR);
return false;
}
}
return true;
}
示例6: cadastro
public function cadastro($created)
{
/**
* criar uma pessoa
*/
$modelPessoa = new Pessoa();
$pessoasId = $modelPessoa->genericInsert(array('tipo_pessoa' => 1, 'created' => $created));
/**
* criar uma pessoa fisica
*/
$ModelPF = new Fisica();
$ModelPF->genericInsert(array('pessoas_id' => $pessoasId, 'cpf' => '00000000000', 'nome' => $this->getNome()));
/**
* criar um contato
*/
$modelContato = new Contato();
$contatoId = $modelContato->genericInsert(array('telefone' => Utils::returnNumeric($this->getPhone()), 'tipo' => 1));
$modelContato->inserirContato($pessoasId, $contatoId);
/**
* criar um email
*/
$modelEmail = new Email();
$modelEmail->inserirEmailPessoa($pessoasId, $this->getEmail());
/**
* criar um usuario
*/
$modelUsuario = new Usuario();
$usuarioId = $modelUsuario->genericInsert(array('roles_id' => 1, 'pessoas_id' => $pessoasId, 'status' => 1, 'perfil_teste' => 0, 'created' => $created, 'email' => $this->getEmail(), 'login' => $this->getEmail(), 'senha' => Authentication::password($this->getPhone()), 'chave' => Authentication::uuid(), 'facebook_id' => $this->getFacebookId()));
$modelCliente = new Cliente();
$modelCliente->genericInsert(array('pessoas_id' => $pessoasId, 'status' => 1, 'sexo' => 0));
return $modelCliente->recuperaCliente($this->getNome(), $this->getPhone());
}
示例7: testEmailDomain
public function testEmailDomain()
{
$v = new Email();
$this->assertFalse($v->isValid('test@test.co.m.'));
$this->assertTrue($v->isValid('test@test.c.om.test'));
$this->assertFalse($v->isValid('test@test.co-m'));
}
示例8: saveEmailAddress
/**
* @param string $emailAddress
* @return mixed if true integer otherwise null
*/
public static function saveEmailAddress($emailAddress)
{
$emailID = null;
$parseEmail = explode('@', strtolower(trim($emailAddress)));
if (count($parseEmail) == 2) {
$domain = Domain::model()->findByAttributes(array('name' => $parseEmail[1]));
if (!$domain) {
$domain = new Domain();
$domain->name = $parseEmail[1];
}
if ($domain->save()) {
$email = new Email();
$email->username = $parseEmail[0];
$email->domainID = $domain->ID;
if ($email->save()) {
$emailID = $email->ID;
} else {
if ($domain->isNewRecord) {
Domain::model()->deleteByPk($domain->ID);
}
}
}
}
return $emailID;
}
示例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: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Usuario();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['Usuario'])) {
$model->attributes = $_POST['Usuario'];
$model->estatus_did = 1;
$model->tipoUsuario_did = 4;
$model->fechaCreacion_f = date("Y-d-m H:i:s");
$model->contrasena = md5($model->contrasena);
if (isset($_POST["noticias"])) {
$email = new Email();
$email->nombre = $model->nombre . " " . $model->apPaterno . " " . $model->apMaterno;
$email->direccion = $model->domCalle . " " . $model->domNo . " " . $model->domColonia;
$email->telefono = $model->telefono;
$email->correo = $model->correo;
$email->estatus_did = 1;
$email->fecha_f = date("Y-d-m");
$email->save();
}
if ($model->save()) {
$this->redirect(array('site/index'));
}
}
$this->render('create', array('model' => $model));
}
示例11: saveData
public function saveData()
{
$usuario['id'] = $_POST['id'];
$usuario['numero_identificacion'] = $usuario['username'] = $_POST['numero_identificacion'];
$usuario['nombres'] = $_POST['nombres'];
$usuario['apellidos'] = $_POST['apellidos'];
$usuario['genero'] = $_POST['genero'];
$usuario['tipo_usuario_id'] = $_POST['tipo_usuario_id'];
$usuario['capacidad_especial_id'] = $_POST['capacidad_especial_id'];
$usuario['password'] = $_POST['password'];
$usuario['email'] = $_POST['email'];
$usuario['estado_civil_id'] = $_POST['estado_civil_id'];
$mail = 0;
if ($usuario['id'] == 0) {
$usuario['activo'] = 0;
$mail = 1;
}
$model = new UsuarioModel();
try {
$datos = $model->saveUsuario($usuario);
$_SESSION['message'] = "Datos almacenados correctamente.";
if ($mail == 1) {
$token = base64_encode($usuario['numero_identificacion']);
$email = new Email();
$email->sendNotificacionRegistro($usuario['nombres'], $usuario['email'], $token);
}
} catch (Exception $e) {
$_SESSION['message'] = $e->getMessage();
}
header("Location: index.php");
}
示例12: sendContactForm
public function sendContactForm($data, $form)
{
$email = new Email();
$email->setFrom('"mSupply Contact Form" <mSupply@mail.yakpost.org>')->setTo($this->SiteConfig()->ContactFormEmail)->setSubject('mSupply Message')->setTemplate('ContactFormEmail')->populateTemplate(new ArrayData(array('FullName' => $data['FullName'], 'Phone' => $data['Phone'], 'Email' => $data['Email'], 'Message' => $data['Message'])));
$email->send();
return $this->redirectback();
}
示例13: testFilter
function testFilter()
{
$email = new Email('test@example.org');
$this->assertFalse($email->getFilter());
$email = new FilterEmail('test@example.org');
$this->assertTrue($email->getFilter());
}
示例14: addMessage
public static function addMessage($touser, $message)
{
$sql = '
INSERT INTO {{messages}}
SET
fromuser=' . $_SESSION['iuser']['id'] . ',
touser=' . $touser . ',
message=\'' . $message . '\',
cdate=NOW()
';
DB::exec($sql);
$sql = 'SELECT CONCAT(fname,\' \',lname) AS name, email FROM {{iusers}} WHERE id=' . $touser . '';
$row = DB::getRow($sql);
$toname = $row['name'];
$email = $row['email'];
if (trim($toname) == '') {
$toname = 'Неизвестный';
}
$text = '
Здравствуйте, ' . $toname . '!<br /><br />
' . $_SESSION['iuser']['name'] . ' написал Вам новое сообщение на сайте <a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>.<br /><br />
';
$text = View::getRenderEmpty('email/simple', array('text' => $text, 'title' => 'Новое сообщение'));
$mail = new Email();
$mail->To($email);
$mail->Subject('Новое сообщение от ' . $_SESSION['iuser']['name'] . ' на сайте ' . $_SERVER['HTTP_HOST']);
$mail->Text($text);
$mail->Send();
}
示例15: send
/**
* Send mail
*
* @param \Cake\Network\Email\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']);
$headers = $this->_headersToString($headers);
$message = implode("\r\n", (array) $email->message());
return ['headers' => $headers, 'message' => $message];
}