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?