我通过php发送邮件有问题。我已经在php.ini中设置了SMTP:
SMTP = xx.xxx.xxx.xx
smtp_port = 25
和我在php发送电子邮件与以下代码:
// Set up parameters
$to = "xpto.87@gmail.com";
$subject = "Title";
$message = "Hello world";
// Send email
$mail = mail($to,$subject,$message);
// Inform the user
if($mail == true)
echo "send mail";
else
echo "dont send";
我收到的总是一个"不要发送",我不知道为什么。有人能帮帮我吗?
我已经成功地使用以下代码从PHP通过GMAIL发送电子邮件:
$from = "who";
$to = "to";
$subject = "subject";
$host = "ssl://smtp.gmail.com";
$port = 465;
$username = "yourusername";
$password = "yourpass";
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp',array ('host' => $host,
'auth' => true,
'port' => $port,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
告诉我它在你的情况下是否有效。