user1740757
user1740757

Reputation: 87

Mail sending functionalities in Suite CRM

Can you please list down the mail sending functionalities provided by Suite CRM. Eg: When the user is assigned to an Account, the user getting a mail notification. But when the user is removed from the account (In the Account 'Edit' page, Change the user by clicking the 'X' button next to the 'Assigned to', then the user is not getting mail that he has been removed.) Please help me on this.

Upvotes: 1

Views: 3329

Answers (2)

user3795237
user3795237

Reputation: 1

// require_once('phpmalier.php');
$mail = new SugarPHPMailer();
//
//                    $mail->setMailerForSystem();
//                    $mail->From = $focus->settings['notify_fromaddress'];
//                    $mail->FromName = $focus->settings['notify_fromname'];
//                    $mail->Subject = $subject;
//                    $mail->IsHTML(true);
//                    $mail->Body = $body;//$html_body;
//                    $mime_type = "application/pdf";
//                    $mail->AddAttachment($sugar_config['upload_dir'] . $file_name.'.pdf', $file_name, 'base64', $m`enter code here`ime_type);
//                    $mail->prepForOutbound();
//                    $mail->AddAddress($To_email);
                    //if (!$mail->Send()) {
                    //$GLOBALS['log']->fatal("Email for Cases# " . $bean->name . " is not sent. Please check Email id of the contact ");
                    //  }

Upvotes: 0

Amitesh Kumar
Amitesh Kumar

Reputation: 3079

Hello i did not work on suitecrm i worked on sugarcrm so i am answering your question according to suitcrm.

1. You have to create a email template for it first.An example of Account module send email on status change .

You can add after save logic_hook to account module.

1) Add following line in your custom/modules/Accounts/logic_hooks.php

$hook_array['before_save'][] = Array(1, 'send ', 'custom/modules/Accounts/send_email.php', 'accountSendEmail', 'send_email');

2) Create a php file named "send_email.php" in "custom/modules/Accounts/" folder.

3) Create email template form email module and get 36 char ID of it.

4) Write following code in custom/modules/Accounts/send_email.php file.

class accountSendEmail{
    function send_email(&$bean, $event, $arguments)
    {
    if (empty($bean->fetched_row)) {
       require_once("include/phpmailer/class.phpmailer.php");
       require_once("modules/Administration/Administration.php");
       require_once("modules/EmailTemplates/EmailTemplate.php");
       $emailtemplate = new EmailTemplate();
       $emailtemplate = $emailtemplate->retrieve("email_template_id");
       $emailtemplate->parsed_entities = null;
       $temp = array();
       $template_data = $emailtemplate->parse_email_template(
       array(
           "subject" => $emailtemplate->subject,
           "body_html" => $emailtemplate->body_html,
           "body" => $emailtemplate->body
           ),
           'Accounts',
           $bean,
           $temp
           );
       $email_body = $template_data["body_html"];
       $email_subject = $template_data["subject"];
       $admin = new Administration();
       $admin->retrieveSettings();
       $mail = new PHPMailer();
       $mail->IsSMTP();
       $mail->SMTPAuth = true;
       $mail->Host = $admin->settings['mail_smtpserver'];
       $mail->SMTPSecure = "ssl";
       $mail->Port = 465;
       $mail->Username = $admin->settings['mail_smtpuser'];
       $mail->Password = $admin->settings['mail_smtppass'];
       $mail->From = $admin->settings['notify_fromaddress'];
       $mail->FromName = $admin->settings['notify_fromname'];
       $mail->Subject = $email_subject;
       $mail->Body = from_html($email_body);
       $mail->IsHTML(true);
       $mail->AddAddress('[email protected]');
       if (!$mail->send()) {
          $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
          $is_send = 'notsend';
       } else {
         $is_send = 'send';
       }
     }
  }
}
  1. Please check this link it help you :

Link 1

Link 2

Link 3

  1. Above steps are to send emails through code , i sugar there is new concept which is PRocess you can send email on process also.

Process

I think this will help you it help me a lot regarding the emails.

Upvotes: 2

Related Questions