2016-05-18 33 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只会让你的生活变得比需要的更难。