1

可能重复:
如何使用 PHP 发送邮件?
无法使用 smtp.gmail.com 发送 php 邮件

我在使用该mail()函数在 PHP 中发送邮件时遇到一些问题。这是我的php代码

<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  ini_set("SMTP", "ssl://smtp.gmail.com");
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("mr.choudhary_2008@rediff.com",$subject,$message,"From:" .$email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='email.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

</body>
</html> 

我得到的错误是:

Warning: mail() [function.mail]: Failed to connect to mailserver at "ssl://smtp.gmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\email.php on line 14

Thank you for using our mail form
4

3 回答 3

0

The mail settings are wrong. Use these settings.

smtp.auth=true
smtp.ssl=true
smtp.tls=true
smtp.username=unm
smtp.password=pwd
smtp.server="smtp.gmail.com";
smtp.port="465"
于 2012-10-25T11:21:26.293 回答
0

检查/usr/sbin/sendmail/usr/lib/sendmail首先。确保你有发送邮件基本。

于 2012-10-25T11:17:37.277 回答
0

尝试这个;

ini_set( SMTP, "ssl://smtp.gmail.com" ); 
ini_set( smtp_port, 425 );
ini_set("username","<youremail>");  
ini_set("password","<yourpassword>");
于 2012-10-25T11:23:22.957 回答