我在通过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";
我得到什么,总是“不发送”,我不知道为什么。有人可以帮帮我吗?
答案 0 :(得分:0)
我已使用以下代码成功通过GMAIL从PHP发送电子邮件:
$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);
告诉我它是否适用于您的情况。