0

長年のリスナー、初めての電話者...

私は最近、PHP に関する O'Reilly の「Head First」の本に取り組み始めました。

このレッスンの目的は、php の「メール」機能がどのように機能するかを示すことでした。そのために、例として使用する次のコードを示しました (簡潔/文脈のために編集)。

$email = $_POST['email'];
$to = 'myemail@myemail.com';
$subject = 'Abduction report';
$message = "$name .  was abducted $when_it_happened  and was gone for $how_long . \n" .
"Number of aliens: $how_many \n" .
"Alien description $alien_description\n" . 
"What they did: $what_they_did \n" .
"Fang spotted: $fang_spotted \n" .
"Other comments: $other";
mail($to, $subject, $message, 'From:' . $email);

- - - - - - - - - - - - - - - - - 編集 - - - - - - - - --------------------

リクエストごとの結果は次のphpinfo()とおりです。

System: Linux infong 2.4 #1 SMP Thu Feb 14 13:02:49 CET 2013 i686 GNU/Linux

Build date: Apr 10 2013 13:38:50

Configure Command: '../configure' '­­program­suffix=5' '­­with­pear=/usr/lib/php5' '­­with­    config­file­path=/usr/lib/php5' '­­with­libxml­dir' '­­with­mysqli' '­­with­kerberos' '­­with­imap­ssl' '­­enable­soap' '­­with­xsl' '­­enable­mbstring=all' '­­with­curl' '­­with­mcrypt' '­­with­gd' '­­with­pdo­mysql' '­­with­freetype­dir' '­­with­libxml­dir' '­­with­mysql' '­­with­zlib' '­­enable­debug=no' '­­enable­safe­mode=no' '­­enable­discard­path=no' '­­with­png­dir' '­­enable­track­vars' '­­with­db' '­­with­gdbm' '­­enable­force­cgi­redirect' '­­enable­fastcgi' '­­with­ttf' '­­enable­ftp' '­­enable­dbase' '­­enable­memory­limit' '­­enable­calendar' '­­enable­wddx' '­­with­jpeg­dir=/usr/src/kundenserver/jpeg­6b' 'enable­bcmath' '­­enable­gd­imgstrttf' '­­enable­shmop' '­­enable­mhash' '­­with­mhash' '­­with­openssl' '­­enable­xslt' '­­with­xslt­sablot' '­­with­dom' '­­with­dom­xslt' '­­with­dom­exslt' '­­with­imap' '­­with­iconv' '­­with­bz2' '­­with­gettext' '­­enable­exif' '­­with­idn' '­­with­sqlite' '­­enable­sqlite­utf8' '­­enable­zip' '­­with­tidy' '­­enable­gd­native­ttf'

Server API: CGI/FastCGI

Virtual Directory Support: disabled

Configuration File (php.ini) Path: /usr/lib/php5

Loaded Configuration File: /usr/lib/php5/php.ini

Scan this dir for additional .ini files: (none)

additional .ini files parsed: (none)

PHP API: 20041225

PHP Extension: 20060613

Debug Build: no

Thread Safety: disabled

Zend Memory Manager: enabled

IPv6 Support: enabled

Registered PHP Streams: https, ftps, compress.zlib, compress.bzip2, php, file, data, http, ftp, zip

Registered Stream Socket Transports: tcp, udp, unix, udg, ssl, sslv3, sslv2, tls

Registered Strem Filters: zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed

フォームに入力して送信した後にメールが届かないことを除いて、すべてが期待どおりに機能します。

「mail()」から $to 変数を削除し、それを静的文字列 (「myemail@myemail.com」) に置き換えた後、適切にフォーマットされた電子メールを受け取りました。

また、「$to」変数をメッセージの本文に連結すると、メール本文内から正しく表示されました。

では、なぜメールの「to」行で使えないのか途方に暮れています。ここで何が欠けていますか?

4

1 に答える 1