用sendmail傳送HTML格式的郵件(轉)
用sendmail傳送HTML格式的郵件(轉)[@more@]先將來自HTML頁面的資料解碼,再呼叫unix系統sendmail命令即可。例如下:#!/usr/local/bin/perl#&readparse;print "Content-type: text/htmlnn";##********* BEGIN BODY********************#******** END BODY************************## EACH VALUE IN THE HTML FORM WILL BE CONTAINED IN# THE THE @VALUE ARRAY.sub readparse {read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};$user_string =~ s/+/ /g;@name_value_pairs = split(/&/,$user_string);foreach $name_value_pair (@name_value_pairs) {($keyword,$value) = split(/=/,$name_value_pair);$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;push(@value, "$value");$user_data{$keyword} = $value;if ($value=~/<!--#exec/) {print "Content-type: text/htmlnnNo SSI permitted";exit;};};};#E-MAIL SUBROUTINE #ADD "&email(to,from,subject,text)" TO YOUR SCRIPT #REMEMBER TO BACKSLASH THE @ WHEN YOU ARE NOT USING IT IN AN ARRAY#FOR EXAMPLE:# $to='robyoung@mediaone.net'; # $from='foo@company.com';# $subject='Thank you for your inquiry';# $text='Dear readernnThank you for your recent inquiry.';# &email($to,$from,$subject,$text);sub email {local($to,$from,$sub,$letter) = @_;$to=~s/@/@/;$from=~s/@/@/;open(MAIL, "|/usr/lib/sendmail -t") || die"Content-type: text/textnnCan't open /usr/lib/sendmail!";print MAIL "To: $ton";print MAIL "From: $fromn";print MAIL "Subject: $subn";print MAIL "$lettern";return close(MAIL);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-942995/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 在Perl中使用sendmail傳送MIME郵件 (轉)AI
- JSP與JavaMail(4)---傳送HTML格式的郵件 (轉)JSJavaAIHTML
- Linux基礎命令---sendmail傳送郵件LinuxAI
- CentOS下使用MSMTP代替Sendmail傳送郵件CentOSAI
- 使用linux的mail命令傳送html格式的郵件LinuxAIHTML
- ASP用JMail、CDO傳送郵件 (轉)AI
- javamail傳送郵件(轉)JavaAI
- linux formail 傳送html郵件LinuxORMAIHTML
- Linux自動下傳送HTML格式並帶附件的郵件LinuxHTML
- 在 CentOS 7 中使用 Sendmail 通過 PHP 傳送郵件CentOSAIPHP
- 郵件的傳送
- 郵件傳送
- 傳送郵件
- Shell指令碼中傳送html郵件的方法指令碼HTML
- 在CentOS7中使用Sendmail通過PHP傳送郵件CentOSAIPHP
- Ubuntu的郵件傳送Ubuntu
- 用oracle傳送電子郵件Oracle
- 用Perl實現郵件傳送
- 用Oracle傳送郵件procedure (zt)Oracle
- SpringBoot整合Mail傳送郵件&傳送模板郵件Spring BootAI
- 請教:如何解決JAVAMAIL傳送html格式郵件時的亂碼問題JavaAIHTML
- Java Mail 郵件傳送(二):簡單封裝的郵件傳送JavaAI封裝
- Laravel 傳送郵件Laravel
- PHP傳送郵件PHP
- Django——郵件傳送Django
- java郵件傳送Java
- Laravel傳送郵件Laravel
- gmail傳送郵件AI
- Oracle郵件傳送Oracle
- java傳送郵件Java
- Powershell郵件傳送
- thinkphp 郵件傳送PHP
- centos 傳送郵件CentOS
- phpcms傳送郵件PHP
- 如何傳送電子郵件到別人郵箱?電子郵件傳送的方法
- golang傳送郵件(qq郵箱)Golang
- 郵件傳送API整理API
- php windows 傳送郵件PHPWindows