php mail function not sending emails / taking too long to send emails

≡放荡痞女 提交于 2020-02-15 10:15:26

问题


I have a rackspace cloud where I want to set up LAMP. the server has CentOS.

I have sendmail installed and the php mail function use this, but it takes too long to send an email using the php mail function

<?php

ini_set('display_errors', true);
error_reporting(E_ALL);

  $to = "email@somedomain.com"
  $subject = "activation code";
  $message = "Activation code: 10";
  $from = "activate@mywebsite.com ";
  $headers = "From: $from";
  if(mail($to, $subject, $message, $headers)) { 
      echo 'success'; 
  }
  else { echo 'deny'; }

but this takes a lot of time, and when I ask rackspace about this they said the mail function might be using a public mailserver to send emails and as the queue is too long it takes time. but I have another email server too.

is there anyway I can get this to work fast? and can I make the send mail installation to use that email server I have ?


回答1:


Try using the PHP Pear Mail package it allows you to send via sendmail, pop, smtp, or imap http://pear.php.net/packages.php?catpid=14&catname=Mail theres also the ability to easily add attachments and queue messages.

I had the same issue on my rackspace cloud and this resolved it.



来源:https://stackoverflow.com/questions/8771645/php-mail-function-not-sending-emails-taking-too-long-to-send-emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!