PHP Mailer Function

PHP Mailer Function

Dummy content goes here
The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.

Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you’ll find online that uses the mail() function directly is just plain wrong! Please don’t be tempted to do it yourself – if you don’t use PHPMailer, there are many other excellent libraries that you should look at before rolling your own – try SwiftMailer, Zend_Mail, eZcomponents etc.

$mail = new PHPMailer();
$mail->SMTPDebug = 0; //Enabled this so you can see what's happening - Dont forget to set to 0 in production
$mail->IsSMTP();             // set mailer to use SMTP
$mail->SMTPSecure = 'ssl';  
$mail->Host = "mail.intelleigentapplications.in";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Port = 465;
$mail->Username = "arun@inteligentapplications.in";  // SMTP username
$mail->Password = "*******"; // SMTP password
$mail->From = "arun@inteligentapplications.in";
$mail->FromName = "HRMS";
$mail->AddAddress($to);                 // name is optional
$mail->AddReplyTo("arun@inteligentapplications.in", "Information");                 
//$mail->AddReplyTo("arun@inteligentapplications.in", "Information");// name is optional

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = $subject;
$mail->Body    = $message;
$mail->AltBody = $message;

if(!$mail->Send())
{
   return($mail->ErrorInfo);
   exit;
}
return("success");
}
Comments are closed.