mail() function disabled on our servers

PHP mail function is one of the way to send out anonymously/spoofed emails. We commonly use this on "contact us" web forms.

To completely eliminate the possibility of php mail() function being exploited, we have disabled this function on our servers. TO send emails you may use phpmailer with smtp auth or any contact form that allow SMTP authorization. A sample script to achieve this is mentioned bellow.


$mail = new PHPMailer(); 

$mail->IsSMTP();                                      // set mailer to use SMTP 
$mail->Host = "";  // specify main and backup server 
$mail->SMTPAuth = true;     // turn on SMTP authentication 
$mail->Username = "";  // SMTP username 
$mail->Password = "yourpassword"; // SMTP password 

$mail->From = ""; 
$mail->FromName = "Mailer"; 
$mail->AddAddress("", "My Name");        // name is optional 
$mail->AddReplyTo("", "Information"); 

$mail->WordWrap = 50;                                 // set word wrap to 50 characters 
$mail->IsHTML(true);                                  // set email format to HTML 

$mail->Subject = "Here is the subject"; 
$mail->Body    = "This is the HTML message body <b>in bold!</b>"; 
$mail->AltBody = "This is the body in plain text for non-HTML mail 

   echo "Message could not be sent. <p>"; 
   echo "Mailer Error: " . $mail->ErrorInfo; 

echo "Message has been sent"; 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I modify the permissions of my files or directories?

You can do that either via FTP (chmod, for more information please refer to your FTP client...

How to setup FTP client and upload files?

In this tutorial we will show you how to setup FileZilla FTP client to upload your files to our...

I have uploaded my files, why can't I see them?

Please always ensure that you have uploaded your files under the public_html folder.If you have...

How to create a user-friendly URL using .htaccess?

If your website is using long URLs, e.g., you can change it...

How to redirect a page to another page or website using .htaccess?

If the page on your website is no longer exist and you want to redirect it to another page or...