Sending Email to Multiple Leads at Once

Hey All, 

Is there functionality built into SugarCRM that allows for an email template to be sent to multiple leads at once? 

I know we can use the checkbox next to the lead to select multiple leads at once to email as shown below: 

the problem there is it will list out every email in the "to" address bar when sent. 


I would like to be able to send a templated email to say 15 leads at once, without listing out every contact the email was sent to, to each customer. 

Any insight or suggestions for this would be appreciated. 

  • -

    I believe you are looking to utilize Campaigns. Campaigns will send an individual email to each user with a template.

    Other options are to use a marketing integration such as Sugar Market, Constant Contact, Mail Chimp, Hubspot, etc.

  • Hey Jeff, 

    Thanks so much for your reply. 

    While the Campaign feature I'm sure would capture the most of the functionality we are looking for, I don't feel it is the right fit.

    This would not be used for lead generation or marketing, more so as a specific follow up that might apply to 10-15 clients, daily. So the automatic scheduling and target list features of Campaigns may not work here. 

    I would more so be looking to a way I could just manually select 10-15 leads, select a follow up template and send that email when needed. 

    Perhaps this functionality does not exist. 

    As always, trying to find ways to minimize manual data entry where possible :) 

  • Hi Josh, 

    If you find the Campaigns module a bit too clunky, and you're not fussed about knowing if they bounced/clicked/opened or allowing them to opt-out of communications (not really advised) - you could use Sugar's main outbound email account and send them via SugarBPM using the Process Definitions module.

    You'll need to create a trigger dropdown field and select records in Leads ListView, then mass-update them to a trigger value.
    (This assumes you're using Sugar Sell/Enterprise as SugarBPM is not in Professional).

    Otherwise, Campaigns could do the trick. Or, as Jeff mentioned, Sugar Market is a good solution.

    James - Sugabyte

  • Hi ,

    I think the best solution available out of the box to meet your needs would be to leverage SugarBPM. You would create a field on the Leads module (e.g. checkbox for 'follow up needed' or a dropdown if there are multiple types of follow up templates) and allow users to mass update that field value. The BPM definition would trigger on that field updating and send an email to each lead individually with the template you have specified.

    One potential detractor with this solution is that the 'from' address on the email would be the email address you have configured under your Admin > Email Settings rather than the individual who initiates the process to send the follow up. 

    If you think a tailored solution would best meet your exact requirements, my company, Upsert, offers development and consultation services where we can deliver the functionality you desire. 

  • One way you could do this, if you want to go down the rabbit hole of programming it yourself is to leverage the MailerFactory.

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Architecture/Email/Mailer_Factory/

    For example I use this to send ONE email to one or more To and Cc addresses from various logic hooks, schedulers etc.
    These are generally for internal emails,  things like  notifications to an entire Team or department, or the assigned user cc the manager etc..

    function sendGroupEmail($ToEmailAdd, $FromEmailAdd, $FromEmailName, $EmailSubject, $EmailBody, $CcEmailAdd = array(), $attach='') {
      include_once('modules/Mailer/MailerFactory.php');
      global $sugar_config;
      $To = array();
      $Cc = array();
    
      if(is_array($ToEmailAdd)){
        $To = $ToEmailAdd;
      }else{
        $To = explode(';',$ToEmailAdd);
      }
    
      if(is_array($CcEmailAdd)){
        $Cc = $CcEmailAdd;
      }else{
        $Cc = explode(';',$CcEmailAdd);
      }
      try{
        $phpMailer = MailerFactory::getSystemDefaultMailer();
        $mailTransmissionProtocol = $phpMailer->getMailTransmissionProtocol();
        $FromEmailIdentity = new EmailIdentity($FromEmailAdd, $FromEmailName);
        $headers = new EmailHeaders();
        $header_array = array(
          'From'=>$FromEmailIdentity,
          'ReplyTo'=>'',
          'Sender'=>$FromEmailIdentity, //mandatory
          'Subject'=>$EmailSubject,
        );
        $headers->buildFromArray($header_array);
        $phpMailer->setHeaders($headers);
        //$phpMailer->setHtmlBody($EmailBody);
        $phpMailer->setTextBody($EmailBody);
    
        foreach($To as $to_addr){
          //note should be new EmailIdentity(<email_address>, <name>)
          //we don't have a name for these
          $phpMailer->addRecipientsTo(new EmailIdentity($to_addr, $to_addr));
        }
        foreach($Cc as $cc_addr){
          //note should be new EmailIdentity(<email_address>, <name>)
          //we don't have a name for these
          $phpMailer->addRecipientsCc(new EmailIdentity($cc_addr, $cc_addr));
        }
        if(!empty($attach)){
          $phpMailer->addAttachment(new Attachment($attach));
        }
        $phpMailer->send();
      }catch(MailerException $me) {
        $message = $me->getMessage();
        $GLOBALS["log"]->fatal(
          "SendGroupEmail: error sending e-mail (method: {$mailTransmissionProtocol}), (error: {$message})"
        );
      }
      return;
    }
    

    And this to send individual emails to one or more recipients

    <?php
      //Function to send Email message
      //one email per recipient
    
    function sendEmail($ToEmailAdd, $FromEmailAdd, $FromEmailName, $EmailSubject, $EmailBody) {
      global $sugar_config;
      require_once ('modules/Emails/Email.php');
      if(is_array($ToEmailAdd)){
        $To = $ToEmailAdd;
      }else{
        $To = explode(';',$ToEmailAdd);
      }
      foreach ($To as $to_addr){
        if (filter_var($to_addr, FILTER_VALIDATE_EMAIL)){
          try{
            $phpMailer = MailerFactory::getSystemDefaultMailer();
            $mailTransmissionProtocol = $phpMailer->getMailTransmissionProtocol();
            $FromEmailIdentity = new EmailIdentity($FromEmailAdd, $FromEmailName);
            $header_array = array(
              'From'=>$FromEmailIdentity,
              'ReplyTo'=>'',
              'Sender'=>$FromEmailIdentity, //mandatory
              'Subject'=>$EmailSubject,
            );
            $phpMailer->constructHeaders($header_array);
            $phpMailer->addRecipientsTo(new EmailIdentity($to_addr, $to_addr));
            $phpMailer->setHtmlBody($EmailBody);
            $phpMailer->send();
          }catch(MailerException $me) {
            $message = $me->getMessage();
            $GLOBALS["log"]->fatal(
              "SendEmail: error sending e-mail (method: {$mailTransmissionProtocol}), (error: {$message})"
            );
            return($message);
          }
        }else{
          $message = 'BAD EMAIL TO:' . $to_addr;
          return($message);
        }
      }
      return;
    }
    ?>
    

    You could even build something that leverages Sugar's APIs to send and log emails...

     
    But I have been on Professional for over a decade, and I've been building my own BPMs for years). 

    If you can use BMP as  suggested or Campaigns as  suggested,

    I would advise you do so.

    PS. This is OLD code and could use some revision for sure Slight smile ...the downside of coding everything is it gets pretty hard to maintain...

  • -

    Sugar 11 BPM would allow you to send from the "Current User"; you can configure the From email address; you are no longer limited to the "system" email for outbound BPM messages.

  • Thanks for the correction, ! In that case, I don't think there are any major detractors on this solution