在ssh2邮件功能中包含php邮件头。使用ssh2以html格式发送电子邮件

在ssh2邮件功能中包含php邮件头。使用ssh2以html格式发送电子邮件,php,html,email,phpmailer,ssh2-exec,Php,Html,Email,Phpmailer,Ssh2 Exec,所以我用ssh2发送电子邮件 <?phpfunction Mailitnow($message, $subject, $to) { include('Net/SSH2.php'); $ssh = new Net_SSH2('my_linux_address'); if (!$ssh->login('user', 'password')) { exit('Login Failed'); } $command = "echo \"{$message}\" | mailx -s \

所以我用ssh2发送电子邮件

<?phpfunction Mailitnow($message, $subject, $to) {
include('Net/SSH2.php');
$ssh = new Net_SSH2('my_linux_address');
if (!$ssh->login('user', 'password')) {
    exit('Login Failed');
}
$command = "echo \"{$message}\" | mailx -s \"{$subject}\" {$to}";
$ssh->exec($command);}?>

但问题是,当我发送html消息时,与使用php mail()函数发送消息时相比,它不会以html的形式发送。我知道那是因为标题

$subject = "Test";

$message = "<html><head>
<title>Test</title>
</head><body><p>hello awesome person. please click the link</p> 
<p><a href='https://stackoverflow.com'>Continue to website...</a></p>   
<p>Thanks </p>
</body>
</html>
";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Mailitnow($message, $subject, $to);
mail($to, $subject, $message, $headers);    
$subject=“Test”;
$message=”
试验
你好,真棒的人。请点击链接

谢谢

"; $headers='MIME版本:1.0'。“\r\n”; $headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”; Mailitnow($message,$subject,$to); 邮件($to、$subject、$message、$headers);

知道如何在my mailitnow函数中包含html标题吗?先谢谢你

您可以使用
-a
选项将消息头附加到
mailx
命令,如下所示:

$command = "echo \"{$message}\" | mailx -a 'Content-Type: text/html' -s \"{$subject}\" {$to}";
可能重复的