bludit/bl-kernel/helpers/email.class.php

42 lines
1.0 KiB
PHP
Raw Normal View History

2015-08-03 02:49:12 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-03-08 18:02:59 +01:00
class Email {
2015-10-19 00:45:58 +02:00
// Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
2015-03-08 18:02:59 +01:00
public static function send($args)
{
2016-05-07 05:22:48 +02:00
// Current time in unixtimestamp
2016-02-26 16:32:18 +01:00
$now = time();
2016-05-07 05:22:48 +02:00
// Domain
$domainParse = parse_url(DOMAIN);
2015-10-19 00:45:58 +02:00
$headers = array();
$headers[] = 'MIME-Version: 1.0';
2015-10-20 05:14:28 +02:00
$headers[] = 'Content-type: text/html; charset=utf-8';
2016-05-07 05:22:48 +02:00
$headers[] = 'Content-Transfer-Encoding: 8bit';
2016-02-26 16:32:18 +01:00
2016-05-07 05:22:48 +02:00
$headers[] = 'From: =?UTF-8?B?'.base64_encode($args['fromName']).'?= <'.$args['from'].'>';
2016-02-26 16:32:18 +01:00
$headers[] = 'Reply-To: '.$args['from'];
$headers[] = 'Return-Path: '.$args['from'];
2016-05-07 05:22:48 +02:00
$headers[] = 'message-id: <'.$now.'webmaster@'.$domainParse['host'].'>';
2015-10-19 00:45:58 +02:00
$headers[] = 'X-Mailer: PHP/'.phpversion();
2015-03-08 18:02:59 +01:00
2016-05-07 05:22:48 +02:00
$subject = '=?UTF-8?B?'.base64_encode($args['subject']).'?=';
2015-03-08 18:02:59 +01:00
$message = '<html>
2015-08-03 02:49:12 +02:00
<head>
2016-05-07 05:22:48 +02:00
<meta charset="UTF-8">
2015-10-20 05:14:28 +02:00
<title>BLUDIT</title>
2015-08-03 02:49:12 +02:00
</head>
2016-05-07 05:22:48 +02:00
<body>
<div>
2015-10-20 05:14:28 +02:00
'.$args['message'].'
2015-08-03 02:49:12 +02:00
</div>
</body>
</html>';
2015-03-08 18:02:59 +01:00
2016-05-07 05:22:48 +02:00
return mail($args['to'], $subject, $message, implode(PHP_EOL, $headers));
2015-03-08 18:02:59 +01:00
}
2016-01-17 22:11:20 +01:00
}