如何使用 php mail() 在收件箱邮件中显示邮件发件人个人资料图片和标题?

How to show the mail sender profile image and title in inbox mail using php mail()?

我在使用 PHP 发送电子邮件时遇到问题 问题是我的电子邮件标题和变量是空白

我的邮件截图:

我使用我的工作电子邮件地址发送电子邮件。 我的脚本是这样的

public static function header($from, $cc = false, $replyTO = null) {
    $headers = "From: " . $from . "\r\n";
    if ($replyTO) {
    $headers .= "Reply-to: ". $replyTO ."\r\n"; }
    if ($cc) {
    $headers .= "CC: ". $cc ."\r\n"; }
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    return $headers;
}

public static function top() {
    return file_get_contents('email/top.php');
}

public static function footer() {
    return file_get_contents('email/bottom.php');;
}

public static function output( $url ) {

    $message = self::top();
    $message .= $url;
    $message .= self::footer();

    return $message;
}

public static function send($from, $to, $subject, $content) {
    if ( mail($to, $subject, $content, self::header($from)) ) {
        return true;
    }

    return false;
}

有什么解决办法吗?提前谢谢你

名字示例

$headers .= 'From: Steven Koelsche <info@koeltech.net>' . "\r\n";
$headers .= 'From: '.$fullname.' <'.$emailaddress.'>' . "\r\n";

我假设图像与 google+ 帐户绑定,您可以向他们注册您当前的电子邮件,然后只需添加您的图像和 vala

发件人姓名:

尝试以下操作:

public static function header($from,$sender_name='', $cc = false, $replyTO = null) {
    $headers = "From: ".$sender_name."<" . $from . "> \r\n";
    if ($replyTO) {
    $headers .= "Reply-to: ". $replyTO ."\r\n"; }
    if ($cc) {
    $headers .= "CC: ". $cc ."\r\n"; }
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    return $headers;
}