2016-05-18 230 views
0

我想下面的代碼發送電子郵件與attachemnts。然而,這個代碼只發送電子郵件而不是附件。如何發送電子郵件與附件中的附件

有人可以幫忙嗎?

open(SENDMAIL, "|/usr/lib/sendmail -oi -t -i") or die "Can't fork for sendmail: $!\n"; 

print SENDMAIL <<"EOF"; 

From: <new\@something.com> 

To: <new\@something.com> 

Cc: <new\@something.com> 

Subject: this is our email 

Content-type: text/plain 

Hi This is the mail 

EOF 

close(SENDMAIL); 

回答

0

mailx - 這裏是解決方案。 echo "Reminder " | mailx -asm\@pe.net -a "location of file" -s "this is email" -asm\@pe.net

3

使用原始Unix命令從Perl發送電子郵件,這種情況大約在20年前過時了。你會更好地尋找一個好的CPAN模塊。

在這種情況下,我建議Email::Stuffer

Email::Stuffer->from('[email protected]') 
       ->to('[email protected]') 
       ->cc('[email protected]') 
       ->subject('this is our email') 
       ->text_body('Hi, this is the email') 
       ->attach_file('your_file.txt') 
       ->send; 

不使用CPAN只會讓你的生活變得比需要的更難。