发送邮件并在本地测试它为php项目

I am doing email verification for my php project , for that I have written the code but the problem is how to check my mails are going to the desired location . Is there any way to send arbitrary mail for checking my code on localhost.Basically I wanted to see my sent mail on localhost. I have xammp installed.

The mail() function usually doesn't work by default for things like WAMP. You will need to add details of your SMTP server to the php.ini file.

Here is a nice tutorial: http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

php.ini file: Search for mail function in that file and replace its content as follow. [mail function]

; For Win32 only.

; http://php.net/smtp

SMTP = your serve’s host name. (ex. mail.test.com)

; http://php.net/smtp-port

smtp_port = 25

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = Sender email Id .(ex. testing@gmail.com

Save the php.ini file. Write code to send mail.

Test message

Hey its working!.. ..

‘; // To send HTML mail, the Content-type header must be set $headers = ’MIME-Version: 1.0′ . ” ”; $headers .= ’Content-type: text/html; charset=iso-8859-1′ . ” ”; // Additional headers $headers .= ’To: Receiver name ’ . ” ”; $headers .= ’From: Sender name ’ . ” ”; // Mail it mail($to, $subject, $message, $headers); ?>