During CRM Customization, their may be requirement araise to send manual mails apart from default emails settedup in the SugarCRM. In those scenarios, you can send html mails through the system..
So Script will be:-
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
include_once('config.php');
require_once('include/SugarLogger/LoggerManager.php');
require_once('data/SugarBean.php');
require_once ('include/TimeDate.php');
require_once('include/entryPoint.php');
require_once('include/MVC/SugarApplication.php');
require_once ('include/modules.php');
require_once('include/utils.php');
require_once("modules/Administration/Administration.php");
require_once('include/SugarEmailAddress/SugarEmailAddress.php');
require_once("include/SugarPHPMailer.php");
//Download the file from Below Library
require_once('include/database/PearDatabase.php');
global $current_user, $timedate;
$db = DBManagerFactory::getInstance();
$to_email = ($_GET['test_email_address']);
if($_GET['test_email_address']=="")
die("To Email Address is missing");
$from_name = ($_GET['from_name']);
$from_email = ($_GET['from_email']);
$host = ($_GET['host']);
$port = ($_GET['port']);
$user_name = ($_GET['user_name']);
$password = ($_GET['password']);
// For Email sending
$mail = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
if ($admin->settings['mail_sendtype'] == "SMTP")
{
$mail->Host = $host;
$mail->Port = $port;
// if ($admin->settings['mail_smtpauth_req'])
// {
$mail->SMTPAuth = TRUE;
$mail->Username = $user_name;
$mail->Password = $password;
// }
$mail->Mailer = "smtp";
// $mail->SMTPSecure = 'ssl';
$mail->SMTPKeepAlive = true;
}
else {
$mail->mailer = 'sendmail';
}
$from = $from_email;
$fromName = $from_name;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->ContentType = "text/html"; //"text/plain"
$mail->IsHTML(true);
$mail->AddAddress($to_email,"");
$mail->Subject = "Client Update Test Email";
$body= "This is a Test Email for Auto Client Update";
$mail->Body = from_html($body);
$success = $mail->Send();
if($success)
{
echo "Email Send";
}
else
{
echo "Error in Email Sending";
}
?>
So Script will be:-
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
include_once('config.php');
require_once('include/SugarLogger/LoggerManager.php');
require_once('data/SugarBean.php');
require_once ('include/TimeDate.php');
require_once('include/entryPoint.php');
require_once('include/MVC/SugarApplication.php');
require_once ('include/modules.php');
require_once('include/utils.php');
require_once("modules/Administration/Administration.php");
require_once('include/SugarEmailAddress/SugarEmailAddress.php');
require_once("include/SugarPHPMailer.php");
//Download the file from Below Library
require_once('include/database/PearDatabase.php');
global $current_user, $timedate;
$db = DBManagerFactory::getInstance();
$to_email = ($_GET['test_email_address']);
if($_GET['test_email_address']=="")
die("To Email Address is missing");
$from_name = ($_GET['from_name']);
$from_email = ($_GET['from_email']);
$host = ($_GET['host']);
$port = ($_GET['port']);
$user_name = ($_GET['user_name']);
$password = ($_GET['password']);
// For Email sending
$mail = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
if ($admin->settings['mail_sendtype'] == "SMTP")
{
$mail->Host = $host;
$mail->Port = $port;
// if ($admin->settings['mail_smtpauth_req'])
// {
$mail->SMTPAuth = TRUE;
$mail->Username = $user_name;
$mail->Password = $password;
// }
$mail->Mailer = "smtp";
// $mail->SMTPSecure = 'ssl';
$mail->SMTPKeepAlive = true;
}
else {
$mail->mailer = 'sendmail';
}
$from = $from_email;
$fromName = $from_name;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->ContentType = "text/html"; //"text/plain"
$mail->IsHTML(true);
$mail->AddAddress($to_email,"");
$mail->Subject = "Client Update Test Email";
$body= "This is a Test Email for Auto Client Update";
$mail->Body = from_html($body);
$success = $mail->Send();
if($success)
{
echo "Email Send";
}
else
{
echo "Error in Email Sending";
}
?>
No comments:
Post a Comment