4

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 ?

hakre
  • 193,403
  • 52
  • 435
  • 836
nivanka
  • 1,352
  • 6
  • 23
  • 36

1 Answers1

0

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.

Clark T.
  • 1,470
  • 2
  • 11
  • 25
  • thanks for the reply, thats an option I cannot use really, cause I am using some CMS to send these and i dont want to change the core of the CMS. – nivanka Jan 13 '12 at 11:38
  • I downvoted because this is not an answer to the question which is about PHP's mail function. Alternative solutions are ok for comments only. You could as well have suggested using a different hosting provider or finding another job... – jacmkno Oct 18 '17 at 03:40