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.



<?php 
require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

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

$mail->From = "youremailid@domain.com"; 
$mail->FromName = "Mailer"; 
$mail->AddAddress("myname@myname.com", "My Name");        // name is optional 
$mail->AddReplyTo("info@example.com", "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 
clients"; 

if(!$mail->Send()) 
{ 
   echo "Message could not be sent. <p>"; 
   echo "Mailer Error: " . $mail->ErrorInfo; 
   exit; 
} 

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. example.com/files/folder/sitemap.html, 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...