浏览代码

解决使用自带Email类发送邮件时,收件人账号名是数组索引的问题

Henry 4 年之前
父节点
当前提交
5ab531e0ec
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      application/common/library/Email.php

+ 6 - 1
application/common/library/Email.php

@@ -176,7 +176,12 @@ class Email
      */
     protected function buildAddress($emails)
     {
-        $emails = is_array($emails) ? $emails : array_flip(explode(',', str_replace(";", ",", $emails)));
+        if (!is_array($emails)) {
+            $emails = array_flip(explode(',', str_replace(";", ",", $emails)));
+            foreach ($emails as $key => $value) {
+                $emails[$key] = strstr($key, '@', true);
+            }
+        }
         return $emails;
     }