简体   繁体   中英

Problems sending email through PHP - configuration issue

I'm having problems sending a mail through php. I've already set in php.ini SMTP:

SMTP = xx.xxx.xxx.xx
smtp_port = 25

And I'm in php to send an email with the following code:

// 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";

What do I get and always a "dont send", and i dont know why. Anybody can help me please?

I have succesfully sent email from PHP over GMAIL using following code:

$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);

Tell me if it works in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM