Commit cae0f12b authored by Jamie Carl's avatar Jamie Carl 🤙🏼

Minor tweaks to email address handling and headers

parent 7a949f3c
......@@ -32,6 +32,6 @@
},
"require": {
"php": "^5.6 || ^7.0",
"hazaarlabs/hazaar-mvc": ">=2.3.0"
"hazaarlabs/hazaar-mvc": "^2.3.60"
}
}
......@@ -66,7 +66,7 @@ class Adapter {
$name = trim($name);
return ($name ? "$name <$email>" : $email);
return ($name ? "\"$name\" <$email>" : $email);
}
......
......@@ -2,6 +2,6 @@
namespace Hazaar\Mail;
class Template extends \Hazaar\View\Template {
class Template extends \Hazaar\Text\Template {
}
......@@ -4,11 +4,16 @@ namespace Hazaar\Mail\Transport;
class Local extends \Hazaar\Mail\Transport {
public function send($to, $subject = NULL, $message = NULL, $extra_headers = array()) {
public function send($to, $subject = NULL, $message = NULL, $headers = array()) {
$sendmail_from = '';
foreach($extra_headers as $key => $value) {
$mail_headers = array();
foreach($headers as $key => $value) {
if(!$value)
continue;
if(strtolower($key) == 'from') {
......@@ -16,24 +21,22 @@ class Local extends \Hazaar\Mail\Transport {
* If this is the from header, try and extract the email address to use in sendmail -f.
* Sometimes emails will not send correctly if this fails
*/
if(preg_match('/[\w\s]*\<(.*)\>/', $value, $matches)) {
if(preg_match('/[\w\s]*\<(.*)\>/', $value, $matches))
$sendmail_from = $matches[1];
} else {
else
$sendmail_from = $value;
}
}
$headers[] = $key . ': ' . trim($value);
$mail_headers[] = $key . ': ' . trim($value);
}
//The @ sign causes errors not to be thrown and allows things to continue. the mail() comment will just return false when not successful.
$ret = @mail($this->formatTo($to), $subject, $message, implode("\n", $headers), ($sendmail_from ? '-f ' . $sendmail_from : NULL));
$mail_headers = implode("\n", $mail_headers);
//The @ sign causes errors not to be thrown and allows things to continue. the mail() command
//will just return false when not successful.
$ret = @mail($this->formatTo($to), $subject, $message, $mail_headers, ($sendmail_from ? '-f ' . $sendmail_from : NULL));
if(!$ret){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment