3

こんにちは、php を使用してメールを送信する必要があります。しかし、単純な電子メールを送信しようとすると、送信されません.理由は何ですか? ヘッダーまたは権限を含める必要がありますか?助けてください。これが私のコードです。

<?php
$to='jyothi.jish@gmail.com';
$message='hai';
mail($to, 'My Subject', $message);
?>

この小さなメッセージでさえ送信されていません. 誰かが理由を推測できますか?

4

3 に答える 3

0

問題は、サーバーでメール送信パラメーターを定義する必要があることです。メールホスト、ポートなど。 http://phpmailer.worxware.com/を使用するのが最適です。gmail などのサードパーティを使用して、localhost 開発環境を介してメールを送信できます。

使用できます

$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';

$mail->Host       = "mail.example.com"; // SMTP server example
$mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "username"; // SMTP account username example
$mail->Password   = "password";        // SMTP account password example

接続パラメータを定義します。

于 2013-11-12T06:49:02.657 に答える
-1

これは、Windows の PHP で XAMPP または WAMP (localhost) からメールを送信する方法です。

a) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMPP server.
Note : Make a backup of php.ini file

b) Search [mail function] in the php.ini file.

You can find like below.
[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

Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25.
Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address..

So , it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.planetghost.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@planetghost.com

c) Restart the XAMPP or WAMP(apache server) so that changes will start working.

d) Now try to send the mail using the mail() function .
于 2013-11-12T06:57:37.317 に答える