1

以下は、HTML メールを送信するために使用した perl コードです。

#!/usr/bin/perl
use strict;
use warnings;
use Switch;
use IO::File;

my $score = 2;
my $to = 'abc@a.com';
my $from = 'def@b.com';
my $subject = "SHV summary report for servers with score $score or higher";
my $mailbody = '<html><body>Hello</body></html>';
open(MAIL,"|/usr/sbin/sendmail -t");
    print MAIL "To: $to\n";
    print MAIL "From: $from\n";
    print MAIL "Subject: $subject\n";
    print MAIL "Content-Type: text/html; charset=utf-8\n\n"
        . "$mailbody";

close(MAIL);

動いていない。メールが届きません。しかし、 open () 呼び出しを次のように置き換えると:

open(MAIL,"|猫 -t");

以下を出力します。

To: abc@a.com
From: def@b.com
Subject: SHV summary report for servers with score 2 or higher
Content-Type: text/html; charset=utf-8

<html><body>Hello</body></html>

私が交換した場合:

my $subject = "SHV summary report for servers with score $score or higher";

と:

my $subject = "SHV summary report for servers with core $score";

その後、すべて正常に動作します。もし私が

「コア」を「スコア」に戻す、または

文字列に「以上」を追加する、または

「SHV スコア $score 以上」に変更します

それは動作を停止します。誰でも理由を知っていますか?

ありがとう、アレックス

4

4 に答える 4

1

に変更します:

open( MAIL, qq(| /usr/sbin/sendmail -t abc\@a.com)) or die "failed on sending email ";
print MAIL "From:$from\n";
print MAIL "To:$to\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: text/html; charset=utf-8\n\n"
print MAIL "\n$mailbody";
于 2013-10-04T21:01:34.060 に答える
0

Mail::SendEasy は、迅速かつ簡単な代替ソリューションであるべきです。

HTML 電子メール、SMTP 認証、添付ファイルなどをサポートします。Mail::SendEasy を使用すると、sendmail プログラムの使用を削減することもできます。そのため、sendmail プログラムに問題や問題がある場合、Mail::SendEasy を使用すると通常は自動的に解決されます。

詳細については、こちらをご覧ください。

于 2013-10-19T12:22:02.073 に答える