2017-07-11 1 views
0

を使用してHTML形式の電子メールを送信するので)私はSSH2ssh2メーリング機能にphpメールヘッダーを含めます。 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が比較して、私は(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

の可能性のある重複(https://stackoverflow.com/questions/24010230/mailx [mailxのは、HTML形式のメッセージを送信します] -send-html-message) – Synchro

答えて

0

このようにあなたは、mailxコマンドに-aオプションでメッセージヘッダを追加することができます。

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