removed deprecated mail_send()
This has been replaced by the Mailer class some years ago.
This commit is contained in:
parent
c1ec88ce7a
commit
656246ffb4
185
inc/mail.php
185
inc/mail.php
|
@ -8,8 +8,6 @@
|
|||
|
||||
// end of line for mail lines - RFC822 says CRLF but postfix (and other MTAs?)
|
||||
// think different
|
||||
use dokuwiki\Extension\Event;
|
||||
|
||||
if(!defined('MAILHEADER_EOL')) define('MAILHEADER_EOL',"\n");
|
||||
#define('MAILHEADER_ASCIIONLY',1);
|
||||
|
||||
|
@ -81,189 +79,6 @@ function mail_setup(){
|
|||
$conf['mailfrom'] = $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* UTF-8 autoencoding replacement for PHPs mail function
|
||||
*
|
||||
* Email address fields (To, From, Cc, Bcc can contain a textpart and an address
|
||||
* like this: 'Andreas Gohr <andi@splitbrain.org>' - the text part is encoded
|
||||
* automatically. You can seperate receivers by commas.
|
||||
*
|
||||
* @param string $to Receiver of the mail (multiple seperated by commas)
|
||||
* @param string $subject Mailsubject
|
||||
* @param string $body Messagebody
|
||||
* @param string $from Sender address
|
||||
* @param string $cc CarbonCopy receiver (multiple seperated by commas)
|
||||
* @param string $bcc BlindCarbonCopy receiver (multiple seperated by commas)
|
||||
* @param string $headers Additional Headers (seperated by MAILHEADER_EOL
|
||||
* @param string $params Additonal Sendmail params (passed to mail())
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
* @see mail()
|
||||
*
|
||||
* @deprecated User the Mailer:: class instead
|
||||
*/
|
||||
function mail_send($to, $subject, $body, $from='', $cc='', $bcc='', $headers=null, $params=null){
|
||||
dbg_deprecated('class Mailer::');
|
||||
$message = compact('to','subject','body','from','cc','bcc','headers','params');
|
||||
return Event::createAndTrigger('MAIL_MESSAGE_SEND',$message,'_mail_send_action');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated User the Mailer:: class instead
|
||||
*/
|
||||
function _mail_send_action($data) {
|
||||
dbg_deprecated('class Mailer::');
|
||||
// retrieve parameters from event data, $to, $subject, $body, $from, $cc, $bcc, $headers, $params
|
||||
$to = $data['to'];
|
||||
$subject = $data['subject'];
|
||||
$body = $data['body'];
|
||||
|
||||
// add robustness in case plugin removes any of these optional values
|
||||
$from = isset($data['from']) ? $data['from'] : '';
|
||||
$cc = isset($data['cc']) ? $data['cc'] : '';
|
||||
$bcc = isset($data['bcc']) ? $data['bcc'] : '';
|
||||
$headers = isset($data['headers']) ? $data['headers'] : null;
|
||||
$params = isset($data['params']) ? $data['params'] : null;
|
||||
|
||||
// discard mail request if no recipients are available
|
||||
if(trim($to) === '' && trim($cc) === '' && trim($bcc) === '') return false;
|
||||
|
||||
// end additional code to support event ... original mail_send() code from here
|
||||
|
||||
if(defined('MAILHEADER_ASCIIONLY')){
|
||||
$subject = \dokuwiki\Utf8\Clean::deaccent($subject);
|
||||
$subject = \dokuwiki\Utf8\Clean::strip($subject);
|
||||
}
|
||||
|
||||
if(!\dokuwiki\Utf8\Clean::isASCII($subject)) {
|
||||
$enc_subj = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?=';
|
||||
// Spaces must be encoded according to rfc2047. Use the "_" shorthand
|
||||
$enc_subj = preg_replace('/ /', '_', $enc_subj);
|
||||
|
||||
// quoted printable has length restriction, use base64 if needed
|
||||
if(strlen($subject) > 74){
|
||||
$enc_subj = '=?UTF-8?B?'.base64_encode($subject).'?=';
|
||||
}
|
||||
|
||||
$subject = $enc_subj;
|
||||
}
|
||||
|
||||
$header = '';
|
||||
|
||||
// No named recipients for To: in Windows (see FS#652)
|
||||
$usenames = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? false : true;
|
||||
|
||||
$to = mail_encode_address($to,'',$usenames);
|
||||
$header .= mail_encode_address($from,'From');
|
||||
$header .= mail_encode_address($cc,'Cc');
|
||||
$header .= mail_encode_address($bcc,'Bcc');
|
||||
$header .= 'MIME-Version: 1.0'.MAILHEADER_EOL;
|
||||
$header .= 'Content-Type: text/plain; charset=UTF-8'.MAILHEADER_EOL;
|
||||
$header .= 'Content-Transfer-Encoding: quoted-printable'.MAILHEADER_EOL;
|
||||
$header .= $headers;
|
||||
$header = trim($header);
|
||||
|
||||
$body = mail_quotedprintable_encode($body);
|
||||
|
||||
if($params == null){
|
||||
return @mail($to,$subject,$body,$header);
|
||||
}else{
|
||||
return @mail($to,$subject,$body,$header,$params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes an email address header
|
||||
*
|
||||
* Unicode characters will be deaccented and encoded
|
||||
* quoted_printable for headers.
|
||||
* Addresses may not contain Non-ASCII data!
|
||||
*
|
||||
* Example:
|
||||
* mail_encode_address("föö <foo@bar.com>, me@somewhere.com","TBcc");
|
||||
*
|
||||
* @param string $string Multiple adresses separated by commas
|
||||
* @param string $header Name of the header (To,Bcc,Cc,...)
|
||||
* @param boolean $names Allow named Recipients?
|
||||
*
|
||||
* @deprecated User the Mailer:: class instead
|
||||
*/
|
||||
function mail_encode_address($string,$header='',$names=true){
|
||||
dbg_deprecated('class Mailer::');
|
||||
$headers = '';
|
||||
$parts = explode(',',$string);
|
||||
foreach ($parts as $part){
|
||||
$part = trim($part);
|
||||
|
||||
// parse address
|
||||
if(preg_match('#(.*?)<(.*?)>#',$part,$matches)){
|
||||
$text = trim($matches[1]);
|
||||
$addr = $matches[2];
|
||||
}else{
|
||||
$addr = $part;
|
||||
}
|
||||
|
||||
// skip empty ones
|
||||
if(empty($addr)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// FIXME: is there a way to encode the localpart of a emailaddress?
|
||||
if(!\dokuwiki\Utf8\Clean::isASCII($addr)){
|
||||
msg(hsc("E-Mail address <$addr> is not ASCII"),-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!mail_isvalid($addr)){
|
||||
msg(hsc("E-Mail address <$addr> is not valid"),-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// text was given
|
||||
if(!empty($text) && $names){
|
||||
// add address quotes
|
||||
$addr = "<$addr>";
|
||||
|
||||
if(defined('MAILHEADER_ASCIIONLY')){
|
||||
$text = \dokuwiki\Utf8\Clean::deaccent($text);
|
||||
$text = \dokuwiki\Utf8\Clean::strip($text);
|
||||
}
|
||||
|
||||
if(!\dokuwiki\Utf8\Clean::isASCII($text)){
|
||||
// put the quotes outside as in =?UTF-8?Q?"Elan Ruusam=C3=A4e"?= vs "=?UTF-8?Q?Elan Ruusam=C3=A4e?="
|
||||
if (preg_match('/^"(.+)"$/', $text, $matches)) {
|
||||
$text = '"=?UTF-8?Q?'.mail_quotedprintable_encode($matches[1], 0).'?="';
|
||||
} else {
|
||||
$text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text, 0).'?=';
|
||||
}
|
||||
// additionally the space character should be encoded as =20 (or each
|
||||
// word QP encoded separately).
|
||||
// however this is needed only in mail headers, not globally in mail_quotedprintable_encode().
|
||||
$text = str_replace(" ", "=20", $text);
|
||||
}
|
||||
}else{
|
||||
$text = '';
|
||||
}
|
||||
|
||||
// add to header comma seperated
|
||||
if($headers != ''){
|
||||
$headers .= ',';
|
||||
if($header) $headers .= MAILHEADER_EOL.' '; // avoid overlong mail headers
|
||||
}
|
||||
$headers .= $text.' '.$addr;
|
||||
}
|
||||
|
||||
if(empty($headers)) return null;
|
||||
|
||||
//if headername was given add it and close correctly
|
||||
if($header) $headers = $header.': '.$headers.MAILHEADER_EOL;
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given mail address is valid
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue