本文整理汇总了PHP中Pimcore\Tool::getMail方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::getMail方法的具体用法?PHP Tool::getMail怎么用?PHP Tool::getMail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::getMail方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lostpasswordAction
public function lostpasswordAction()
{
$username = $this->getParam("username");
if ($username) {
$user = User::getByName($username);
if (!$user instanceof User) {
$this->view->error = "user unknown";
} else {
if ($user->isActive()) {
if ($user->getEmail()) {
$token = Tool\Authentication::generateToken($username, $user->getPassword());
$uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
$loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token . "&reset=true";
try {
$mail = Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
$mail->setIgnoreDebugMode(true);
$mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
$mail->send();
$this->view->success = true;
} catch (\Exception $e) {
$this->view->error = "could not send email";
}
} else {
$this->view->error = "user has no email address";
}
} else {
$this->view->error = "user inactive";
}
}
}
}
示例2: send
/**
* @param string $content
* @param array $records
*/
public function send($content, array $records)
{
$mail = Tool::getMail(array($this->address), "pimcore log notification");
$mail->setIgnoreDebugMode(true);
$mail->setBodyText($content);
$mail->send();
}
示例3: mail
/**
*
*/
public function mail()
{
$conf = Config::getSystemConfig();
if (!empty($conf->general->logrecipient)) {
\Logger::debug(get_class($this) . ": detected log recipient:" . $conf->general->logrecipient);
$user = User::getById($conf->general->logrecipient);
\Logger::debug(get_class($this) . ": detected log recipient:" . $user->getEmail());
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
\Logger::debug(get_class($this) . ": user is valid");
if (!empty($email)) {
if (is_dir(PIMCORE_LOG_MAIL_TEMP)) {
\Logger::debug(get_class($this) . ": detected mail log dir");
\Logger::debug(get_class($this) . ": opening dir " . PIMCORE_LOG_MAIL_TEMP);
if ($handle = opendir(PIMCORE_LOG_MAIL_TEMP)) {
\Logger::debug(get_class($this) . ": reading dir " . PIMCORE_LOG_MAIL_TEMP);
while (false !== ($file = readdir($handle))) {
\Logger::debug(get_class($this) . ": detected file " . $file);
if (is_file(PIMCORE_LOG_MAIL_TEMP . "/" . $file) and is_writable(PIMCORE_LOG_MAIL_TEMP . "/" . $file)) {
$now = time();
$threshold = 1 * 60 * 15;
$fileModified = filemtime(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
\Logger::debug(get_class($this) . ": file is writeable and was last modified: " . $fileModified);
if ($fileModified !== FALSE and $fileModified < $now - $threshold) {
$mail = Tool::getMail(array($email), "pimcore log notification - " . $file);
$mail->setIgnoreDebugMode(true);
$mail->setBodyText(file_get_contents(PIMCORE_LOG_MAIL_TEMP . "/" . $file));
$mail->send();
@unlink(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
\Logger::debug(get_class($this) . ": sent mail and deleted temp log file " . $file);
} else {
if ($fileModified > $now - $threshold) {
\Logger::debug(get_class($this) . ": leaving temp log file alone because file [ {$file} ] was written to within the last 15 minutes");
}
}
}
}
}
}
} else {
\Logger::err(get_class($this) . ": Cannot send mail to configured log user [" . $user->getName() . "] because email is empty");
}
} else {
\Logger::err(get_class($this) . ": Cannot send mail to configured log user. User is either null or not an admin");
}
} else {
\Logger::debug(get_class($this) . ": No log recipient configured");
}
}
示例4: initLogger
/**
* @static
*
*/
public static function initLogger()
{
// for forks, etc ...
\Logger::resetLoggers();
// try to load configuration
$conf = Config::getSystemConfig();
if ($conf) {
// redirect php error_log to /website/var/log/php.log
if ($conf->general->custom_php_logfile) {
$phpLog = PIMCORE_LOG_DIRECTORY . "/php.log";
if (!file_exists($phpLog)) {
touch($phpLog);
}
if (is_writable($phpLog)) {
ini_set("error_log", $phpLog);
ini_set("log_errors", "1");
}
}
}
if (!is_file(PIMCORE_LOG_DEBUG)) {
if (is_writable(dirname(PIMCORE_LOG_DEBUG))) {
File::put(PIMCORE_LOG_DEBUG, "AUTOCREATE\n");
}
}
$prioMapping = array("debug" => \Zend_Log::DEBUG, "info" => \Zend_Log::INFO, "notice" => \Zend_Log::NOTICE, "warning" => \Zend_Log::WARN, "error" => \Zend_Log::ERR, "critical" => \Zend_Log::CRIT, "alert" => \Zend_Log::ALERT, "emergency" => \Zend_Log::EMERG);
$prios = array();
if ($conf && $conf->general->debugloglevel) {
$prioMapping = array_reverse($prioMapping);
foreach ($prioMapping as $level => $state) {
$prios[] = $prioMapping[$level];
if ($level == $conf->general->debugloglevel) {
break;
}
}
} else {
// log everything if config isn't loaded (eg. at the installer)
foreach ($prioMapping as $p) {
$prios[] = $p;
}
}
\Logger::setPriorities($prios);
if (is_writable(PIMCORE_LOG_DEBUG)) {
// check for big logfile, empty it if it's bigger than about 200M
if (filesize(PIMCORE_LOG_DEBUG) > 200000000) {
rename(PIMCORE_LOG_DEBUG, PIMCORE_LOG_DEBUG . "-archive-" . date("m-d-Y-H-i"));
// archive log (will be cleaned up by maintenance)
File::put(PIMCORE_LOG_DEBUG, "");
}
if (!empty($prios)) {
$writerFile = new \Zend_Log_Writer_Stream(PIMCORE_LOG_DEBUG);
$loggerFile = new \Zend_Log($writerFile);
\Logger::addLogger($loggerFile);
}
$conf = Config::getSystemConfig();
if ($conf) {
//email logger
if (!empty($conf->general->logrecipient)) {
$user = User::getById($conf->general->logrecipient);
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
if (!empty($email)) {
$mail = Tool::getMail(array($email), "pimcore log notification");
$mail->setIgnoreDebugMode(true);
if (!is_dir(PIMCORE_LOG_MAIL_TEMP)) {
File::mkdir(PIMCORE_LOG_MAIL_TEMP);
}
$tempfile = PIMCORE_LOG_MAIL_TEMP . "/log-" . uniqid() . ".log";
$writerEmail = new \Pimcore\Log\Writer\Mail($tempfile, $mail);
$loggerEmail = new \Zend_Log($writerEmail);
\Logger::addLogger($loggerEmail);
}
}
}
}
} else {
// try to use syslog instead
try {
$writerSyslog = new \Zend_Log_Writer_Syslog(array('application' => 'pimcore'));
$loggerSyslog = new \Zend_Log($writerSyslog);
\Logger::addLogger($loggerSyslog);
} catch (\Exception $e) {
}
}
if (array_key_exists("pimcore_log", $_REQUEST) && self::inDebugMode()) {
if (empty($_REQUEST["pimcore_log"])) {
$requestLogName = date("Y-m-d_H-i-s");
} else {
$requestLogName = $_REQUEST["pimcore_log"];
}
$requestLogFile = dirname(PIMCORE_LOG_DEBUG) . "/request-" . $requestLogName . ".log";
if (!file_exists($requestLogFile)) {
File::put($requestLogFile, "");
}
$writerRequestLog = new \Zend_Log_Writer_Stream($requestLogFile);
$loggerRequest = new \Zend_Log($writerRequestLog);
\Logger::addLogger($loggerRequest);
//.........这里部分代码省略.........
示例5: featureBug
protected function featureBug()
{
$conf = \Pimcore\Config::getSystemConfig();
$email = $conf->general->contactemail;
$this->view->contactEmail = $email;
if (!$this->getParam("submit")) {
if (HtmlToImage::isSupported()) {
$file = PIMCORE_TEMPORARY_DIRECTORY . "/screen-" . uniqid() . ".jpeg";
HtmlToImage::convert($this->getParam("url"), $file, 1280, "jpeg");
$this->view->image = str_replace(PIMCORE_DOCUMENT_ROOT, "", $file);
}
} else {
// send the request
$type = $this->view->type;
$urlParts = parse_url($this->getParam("url"));
$subject = "Feature Request for ";
if ($type == "bug") {
$subject = "Bug Report for ";
}
$subject .= $urlParts["host"];
$mail = \Pimcore\Tool::getMail($email, $subject, "UTF-8");
$mail->setIgnoreDebugMode(true);
$bodyText = "URL: " . $this->getParam("url") . "\n\n";
$bodyText .= "Description: \n\n" . $this->getParam("description");
$image = null;
if (HtmlToImage::isSupported()) {
$markers = \Zend_Json::decode($this->getParam("markers"));
$screenFile = PIMCORE_DOCUMENT_ROOT . $this->getParam("screenshot");
list($width, $height) = getimagesize($screenFile);
$im = imagecreatefromjpeg($screenFile);
$font = PIMCORE_DOCUMENT_ROOT . "/pimcore/static6/font/vera.ttf";
$fontSize = 10;
if ($markers && count($markers) > 0) {
foreach ($markers as $marker) {
// set up array of points for polygon
$x = $marker["position"]["left"] * $width / 100;
$y = $marker["position"]["top"] * $height / 100;
$bbox = imagettfbbox($fontSize, 0, $font, $marker["text"]);
$textWidth = $bbox[4] + 10;
$values = array($x, $y, $x - 10, $y - 10, $x - 10, $y - 40, $x + $textWidth, $y - 40, $x + $textWidth, $y - 10, $x + 10, $y - 10);
$textcolor = imagecolorallocate($im, 255, 255, 255);
$bgcolor = imagecolorallocatealpha($im, 0, 0, 0, 30);
// draw a polygon
imagefilledpolygon($im, $values, 6, $bgcolor);
imagettftext($im, $fontSize, 0, $x, $y - 20, $textcolor, $font, $marker["text"]);
}
}
imagejpeg($im, $screenFile);
imagedestroy($im);
$image = file_get_contents($screenFile);
unlink($screenFile);
}
if ($image) {
$bodyText .= "\n\n\nsee attached file: screen.jpg";
$at = $mail->createAttachment($image);
$at->type = 'image/jpeg';
$at->disposition = \Zend_Mime::DISPOSITION_ATTACHMENT;
$at->encoding = \Zend_Mime::ENCODING_BASE64;
$at->filename = 'screen.jpg';
}
if ($type == "bug") {
$bodyText .= "\n\n";
$bodyText .= "Details: \n\n";
foreach ($_SERVER as $key => $value) {
$bodyText .= $key . " => " . $value . "\n";
}
}
$mail->setBodyText($bodyText);
$mail->send();
}
$this->renderScript("/admin-button/feature-bug.php");
}