フォームメールを仕込む

http://www.web-liberty.net/の「Web Mail Plus」というcgiFlashスクリプトを使ったメールフォームを随分と前に作成してほったらかしにしておいたらエラーが出始めて困っているので作り直しを決意してみた。
 
今回使うのはMAIL FORM PRO SCRIPT CGI
 

MAIL FORM PRO SCRIPT CGIの導入前の困ったこと

  • 商用利用とかライセンスについての記述が見つけられない
  • 作成者の写真を見て不安になる

自分の確認

#telnet
whereis perl
perl: /usr/bin/perl

whereis sendmail
sendmail: /usr/sbin/sendmail

設置

/cgi-bin/cgiwrap/を噛ます必要があってcheck.cgiにアクセスしたら出てきたエラーがコチラ

CGIWrap Error: Script Execution Failed

CGIWrap encountered an error while attempting to execute this script:

Error Message: No such file or directory
Error Number: 2

This message usually indicates there is a problem with the script itself. Often this indicates either that the #! line of the script is incorrect, or the script was uploaded in binary mode instead of ascii mode. Check to make sure that the script does not have control-M's at the end of every line. That will prevent it from executing. An easy fix that takes care of this most of the time is to put '#!/.../perl --' instead of '#!/.../perl' on the first line of the script. This is typically a problem if the script was edited or uploaded from a DOS/Windows/Macintosh station to a unix based server.

If you are not the owner of this script, please forward this error and the URL that caused it to the script owner. That is often the component in the URL right after /cgiwrap/.

2日悩んだ解決策が

#!/usr/bin/perl --

「 --」を末尾に加えること。エラーメッセージを読み直すと書いてあるし・・・


対策が分かったのでexample.htmlにとりかかる 
次のエラーが「include.cgi」が500になっているとFirefoxが教えてくれた。

include.cgi

#!/usr/bin/perl --

use Jcode;
require 'functions.cgi';
require 'config.cgi';

Jcodeが無いので「http://search.cpan.org/~dankogai/Jcode-2.07/Jcode.pm」からダウンロード、Jcode.pmとJcodeディレクトリをmailformproの中にぶち込む。
 
送信ボタンを押してみると

Software error:

Can't locate LWP/UserAgent.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at
/hogehoge/mailformpro/send.cgi line 94.

コレを見ると

モジュールがいろいろとインストールされてないって事ですね。
Perlの足りないモジュールをインストールするか、Perlのバージョンを上げる必要がありますが、
使っていないモジュールであればコメントアウトすることで回避することができます。

ver.2.1.3の場合

send.cgiの56行目
#use DBI;

94行目、95行目の
#use LWP::UserAgent;
#use HTTP::Request::Common qw(POST);

function.cgiの617行目
#use Net::SMTP;
619行目
#use Net::POP3;


送信ボタンをポチっとすると出たのがコレ

CGIWrap Error: Execution of this script not permitted
Execution of (ja/contact/mail/thanks.html) is not permitted for the following reason:
Script is not executable. Issue 'chmod 755 filename'

 

config.gciの44行目
$config{"thanks_url"} = '../thanks.html';

相対パスから絶対パスに書き換える
 
さんくすページまでは出たけど、メールが届かない(´・ω・`)
SMTPを有効にしてSMTPサーバアドレスを指定する

function.cgiの617行目
use Net::SMTP;

config.cgiの195行目
$config{'SMTPserver'} = 'smtp.example.com';

 
届くようになった(;゚∀゚)=3ムッハー
 
届いたメールに問題がまだある。

  • 受付番号が入らない(メール送信できないときはthanks.htmlにも入っていたのに)
  • 送信元が空欄

他にも空欄があるかな・・・

$config{"serial_file"} = './data/dat.serial.cgi';

dataの中にアクセスするファイルはフルパスで書いてはよくないらしい。

1から5の間の「3.送信の確認」をすっ飛ばす

example_phase_input.htmlの1から5の間の「3.送信の確認」をすっ飛ばしたい。

#消す
<li>&gt;</li>
<li id="mfp_phase_3_label" class="mfp_phase_disabled">3.送信の確認</li>


#2と3を合体
<div id="mfp_phase_2" class="mfp_phase_section">
	<h3 id="mfp_phase_2_title" class="mfp_phase_title"><a name="phase_2" id="phase_2">2.ご用件の入力</a></h3>
	<dl class="mailform">
		<dt><img src="images/mfp_must.gif" width="30" height="16" alt="必須" class="must" />ご用件<span>inquiry body</span></dt>
		<dd class="mfptr"><textarea name="ご用件(必須)" rows="20" cols="80" class="mfp"></textarea><div id="errormsg_ご用件" class="mfp_err"></div></dd>
	</dl>
	<div class="mfp_buttons">
		<ul>
			<li><input type="button" value="" id="button_mfp_reset" onclick="mfp_reset(this.form)" onkeypress="mfp_reset(this.form)" onmouseover="mfp_bt(this,1)" onmouseout="mfp_bt(this,0)" /></li>
			<li><input type="button" value="" id="button_mfp_goconfirm" onclick="sendMail(this.form)" onkeypress="sendMail(this.form)" onmouseover="mfp_bt(this,1)" onmouseout="mfp_bt(this,0)" /></li>
		</ul>
	</div>
	<div class="mfp_phase_buttons">
		<input type="button" value="&lt; 前へ戻る" class="mfp_phase_prev" onclick="mfp_phase_change(2,1)" onkeypress="mfp_phase_change(2,1)" onmouseover="mfp_bt(this,1)" onmouseout="mfp_bt(this,0)" />
	</div>
</div>

#3を消す
<div id="mfp_phase_3" class="mfp_phase_section">〜</div>

パーミッションの変更

普通の".cgi"は705、"data/dat.*cgi"は600にした。
function.cgiでゴニョゴニョしているから必要ないとおもう。
 

メールのFrom問題

kenmituo@example.comと入力した場合、Fromが「kenmituo 」となって嫌な感じなので対策する。

#function.cgi

  $fromname = Jcode->new($fromname)->mime_encode;
  my @temp = split(/@/, $fromname);
# $fromname = "${fromname} <${mailfrom}>";
  $fromname = "@temp[0] <${mailfrom}>";

 

IEだけテーブルの背景が出ない

「mfptr」のところが出ない。

html5doctor.com Reset Stylesheet

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
/* background:transparent;*/
}

リセットスタイルシートの「background:transparent;」の扱いがIEchromeなどと異なるのが原因だったよ、、、