2017-07-11 92 views
0

所以我發送電子郵件使用SSH2包含PHP郵件標題在ssh2郵件功能。發送使用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格式的電子郵件,但問題是,當我發送HTML郵件不被髮送的HTML,當我使用PHP郵件發給相比()功能。我知道那是因爲標題。

$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);  

任何想法如何在我的mailitnow函數中包含html標頭?提前致謝。

+0

[mailx的發送HTML消息](可能的重複https://stackoverflow.com/questions/24010230/mailx - 發送-HTML的消息) – Synchro

回答

0

您可以將郵件標題與-a選項的mailx命令,就像這樣:

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