作者 邓超

解析邮件 编码问题

... ... @@ -77,6 +77,14 @@ class Address {
* @time 2024/9/11 11:43
*/
private function pregEmail(string $str):string {
$str = trim($str);
if(substr($str,-1) == '>'){
$email = substr($str,strrpos($str,'<'));
if($email){
return trim(str_replace(['<','>'],'',$email));
}
}
preg_match_all('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email);
if(!empty($email[0])){
$email = end($email[0]);
... ...
... ... @@ -79,7 +79,7 @@ class Header{
// 头信息content-type
$contentType = $this->get('content-type');
if($contentType){
preg_match("/charset=\"?([a-z0-9-._]{2,})\"?/",$contentType,$charset);
preg_match("/charset=\"?([a-z0-9-._]{2,})\"?/i",$contentType,$charset);
if(!empty($charset[1])){
// 编码
$this->setAttribute('charset',$charset[1]);
... ...