Hi,
i faced some problem to use sugar email functionality so i create new feature which is send mail as a part of sugar. By this i can send mail local server as well so no need to upload and check the email functionality.
i putting the code
this is a simple code which helps you to send a mail using phpmailer in sugarcrm.PHP Code:
class customScript extends SugarBean
{
function customScript($focusObjectId,$foucsObjectType)
{
// body
.................
..................
// define variable
$to=..............;
$subject=.............;
$body=................;
$this->send_mail($to,$subject,$body);
}
function send_mail($to,$subject,$body){
require_once("include/phpmailer/class.phpmailer.php");
$mail = new PHPMailer(); // Instantiate your new class
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->SMTPSecure= "ssl"; // Used instead of TLS when only POP mail is selected
$mail->Port = 465; // Used instead of 587 when only POP mail is selected
$mail->Username = "yourgmailid"; // SMTP username, you could use your google apps address too.
$mail->Password = "yourgmailpwd"; // SMTP password
$mail->From = "yourgmailid"; //Aparently must be the same as the UserName
$mail->FromName = "Test";
$mail->Subject = $subject;
$mail->Body = $body;
$mail->IsHTML(true);
$mail->AddAddress($to);
if(!$mail->Send())
{
echo "There was an error sending the message:" . $mail->ErrorInfo;
exit;
}
}
}
may be my code help you
feel free to ask
thanks


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks