@tattyan3 (tatsuji shimo)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

なぜか、私だけ上手く行かない?

Mercuryでtestmailを出してみたい。

phpでトライしたが、項目不足で失敗した?。
perl5でトライしたが、何かがない?。

例)
#!C:/xampp/Perl/bin/perl5.32.1
#!//usr/bin/perl

#てててててててててててててててててててて
#│ POST-MAIL : postmail.cgi - 2019/10/14
#│ copyright (c) kentweb, 1997-2019
#│ http://www.kent-web.com/
#すすすすすすすすすすすすすすすすすすすす
#+ Mercury test 2024/1/9

adoress http://127.0.0.1/perl_test/postmail/postmail.cgi ダイレクト呼び出し禁止。

http://127.0.0.1/perl_test/postmail/index.html ここから呼んでください。

解決方法を教えて下さい。

発生している問題・エラー

Software error:

例)

For help, please send mail to the webmaster (Mercuryの依存する@localhost), giving this error message and the time and date of the error.

該当するソースコード

	$Mercury_cool = 'on';
	if ($Mercury_cool eq 'on'){	
		print "Content-type: text/html; charset=utf-8\n\n";
		print <<EOF ;
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<title>Mercury Test</title>
</head>
<body>
EOF
		if ($email eq 'naisyo@localhost' && $Mercury_cool eq 'on'){
			my $n =0;
print "in stepp1<br>\n";
			use Net::SMTP;
print "in stepp2<br>\n";
# port587に接続する Mercury port587portはMercuryに無い。die;
			my $smtp = Net::SMTP->mail('naisyo@localhost <naisyo@localhost> ', Port => 25) or $n=1;
if($n==1){print "1<br>";}
print "in stepp3<br>\n";
			$smtp->mail('naisyo@localhost <naisyo@localhost> ') or $n=2;
if($n==2){print "2<br>";}			
print "in stepp4<br>\n";			
			$smtp->to($email) or $n=3;
if($n==3){print "to: $email<br>";}			
print "in stepp5<br>\n";
			$smtp->data($date2) or $n=4;
if($n==4){print "date: $date2<br>";}			
print "in stepp6<br>\n";
			$smtp->datasend($res_body) or $n=5;
if($n==5){print "res_body: error<br>";}			
print "in stepp7<br>\n";
			$smtp->dataend() or $n=6;
if($n==6){print "Cant send data<br>";}			
			# 接続を切断する
print "in stepp8<br>\n";			
			$smtp->quit() or $n=7;
if($n==7){print "Cant quit<br>";}			
print "in all end.<br>\n";			
		}
		print <<EOF ;
<h2>Mercury Test</h2>
</body>
</html>
EOF
		exit;
	}

こちらも一日かかったが、どうにもできず。

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>テスト書き出し</title>
</head>
<BODY BGCOLOR="#ffffff">
試験
<p>
<?php
//@@@@@@@@@@@@@@@@@@@@@@@ bad iteme @@@@@@@@@@@@@@@@@@@@@@@@@@@@
//<----------------------------
// this   Mercury_test_php.php
// adress http://localhost/php_test/Mercury_test_php.php
// day    2024/1/7 Qiita reference
// ;///////////////// php.ini addition.
// ; mail Mercury
// ;/////////////////
// [mail function]
// ; For Win32 only.
// ; http://php.net/smtp
// SMTP = localhost
// ; http://php.net/smtp-port
// smtp_port = 25
//
// ; For Win32 only.
// ; http://php.net/sendmail-from
// ; sendmail_from = (送信元として利用するメールアドレス)postmaster@localhost
// sendmail_from = Mercury@mail.test.jp
//
// ;/////////////////
// ; mail Mercury end
// ;///////////////// xampp in php
//----------------------------- end information.

// $to = "your@adoress.jp";
///////////////////////
都合により出せません//
///////////////////////
$body = base64_encode($body);

// 以上の設定から下記のメールヘッダーが想定される。
$mailHeaders = <<< EOF
to: $to
From: $senderName
Subject: test@nantokayaruyo.com
MIME-Version: 1.0
Date: 日付がねぇ
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64 
X-Mailer: mypostmail v0.01

EOF;
// Content-Type: メール本文はUTF-8でエンコードされる
// Content-Transfer-Encoding: ただし、送信時はbase64化する

// ini_set(); 

print("おおっ、世の中よ!");

$resive = mail($to, $title, $body, $mailHeaders);

var_dump($resive);

print("おおっ、世の中よ!");

?>
</p>
</body>
</html>

自分で試したこと

忘れる程、いろいろやりました。試したことを記載してください。

1 likes

1Answer

ダイレクト呼び出し禁止。

の意図が理解できません。結局、index.htmlからJavaScriptかform submitでpostmsil.cgiをコールするだけですが?

複数のサンプルを参考にして下さい。

0Like

Comments

  1. @tattyan3

    Questioner

    postmail.cgiを直接アドレスを与えず呼び出すと、"不正なアクセスです"となるからindex.htmlから与えて呼び足してください。と言う意味。です。
    xampp3.3.0は1.7.7とは違うようなんですよね。色々探したけど見つかりません。

  2. mail関数のサンプルです。
    form submitのサンプルもあります。

    合わせてphp.iniも編集して下さい。

  3. @tattyan3

    Questioner

    分かりやすく書いてありますね。localhostじゃ、Mercury使わないとテスト出来ないのが、難点ですよね。半日かかって、xampp1.7.7(zip)立ち上げましたzipだからディレクトリはハンドメイドで編集しました。大変だった。しばらく休んでコピペに来ます。ちなみに25番portダメなん?Outlookの受信ボックス設定とか他の人と重なるアドレスはダメとかあったりして、難航しています。あなたも、難儀しているようですね。取り合えず、ありがとうございます。

Your answer might help someone💌