Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

email - How to send mail using PHP?

I'm using Windows Vista OS. PHP, MySQL as the database and Apache web server.

I want to send notification to those who want to join in my site. But the problem is when I click submit. It doesn't send anything to the email address of the user.

What to do you think is the best solution for this?

<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,

How are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have several options:

  • there's built in mail function, but it requires that some MTA is running on the machine, doesn't support authentication, and you'll need to work hard to send attachments
  • there's Pear Mail package, if you like to use Pear stuff
  • there's a good PHPMailer class which I used in past few years and it works really great. It like it because it is very simple and easy to include in your project (just a simple include call), yet powerful

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...