我正在尝试使用 php 发送邮件。我正在使用 WampServer。所以我尝试了以下代码
ini_set("SMTP","smtp.gmail.com" );
ini_set("smtp_port","465");
ini_set('sendmail_from', 'person1@gmail.com');
$to = "person2@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "person1@gmail.com";
$headers = "From:" . $from;
$retval = mail($to,$subject,$message,$headers);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
但连接需要更多时间,并说无法与 localhost 连接。请帮我解决问题