Opt out and Trackers for Workflow Emails

I have a WebToPerson form set up to capture leads coming from our website. A workflow fires off a welcome email to the new subscriber which is working well.

Problem is, Suite has no way to add an opt-out link to workflow emails nor any way to track opens and click throughs unless it’s part of a campaign. In my situation the lead is considered ‘subscribed’ at the point they’re created by the WebToPerson form so will need some way of opting out.

What I’m wondering is how achievable are the following workarounds to this conundrum:

Option 1:

  • Create a workflow that generates an opt-out link for that lead link by somehow fudging the same internal workflow Suite uses to generate the opt-out link (tied to the campaign the new lead is assigned to)

Option 2:

Create a workflow to:

  1. Create a new Target List
  2. Add the lead to the new target list (as only member)
  3. Add target list to the campaign\
  4. Send the campaign to that target list only
  5. Force send the email queue (for immediate delivery)
  6. Delete the target list

That way the opt-out link and tracking links will be directly applied and visible in the Campaigns and Lead views.

Is this possible? Is there a better way of achieving my needs?


1 Like


I think Option 2 might be the closest to what you’d like to achieve OOTB, though i’m not sure if its possible to relate Target Lists & force-send Campaigns through Workflow actions.

If you have some coding experience, another method may be to have a look into either building custom WebToLeadCapture.php functionality, (file found in modules/Campaigns/)

Or, building a Custom entrypoint, and linking this Entrypoint in the Email Template.

I have found an old Github repository that a Forum Poster has linked to in the past, that has examples of both, hopefully it’ll be of some use: https://github.com/audoxcl/SugarCRMEntryPoints

Hello @Dogamondo

I too am in almost the exact same position :face_with_monocle: I did not expect to be, but here we are together! :rofl:

Did you / How did you resolve your issue of “opt-out” not working for emails sent via workflow?

Quite important for me, and most likely all, to have the option to opt-out on any emails sent out.

Can anyone with ideas to resolve please chime in, thank you all.
Best Regards

Referenced similar topics
Is it possible to add an opt-out link for emails that are sent via workflow?

Seems you’d need to do some customizations to get an unsubscribe link to work for workflow emails.

One solution to try would be to is to create a general email newsletter campaign to source an opt out link.

  1. I would suggest making a checkbox inside the lead, indicating the unsubscribe from mailings.
  2. I would make a custom entry point, so that inside it, by url, I would send the id of the lead that refuses to be sent. when switching to such an entry point, put a tick in the checkbox.
  3. set up the workflow so that they would check the absence of this checkmark in the checkbox.
1 Like


Try this

  1. goto modules\AOW_Actions\actions\actionSendEmail.php
  2. In function sendEmail , Before mail->Send() function add this line,
$mail->Body .= "Please unsubscribe  <a ='".$cleanUrl."/index.php?entryPoint=optout&identifier=".$toaddr."'>here</a>";

(add href to anchor tag, I have removed the href attribute to display the URL of optout )

  1. For Getting clean URL , just use below (put somewhere above unsubscribe code/line)
      $toaddr= base64_encode($emailTo[0]);
      $parsedSiteUrl = parse_url($sugar_config['site_url']);
      $host = $parsedSiteUrl['host'];
      if(!isset($parsedSiteUrl['port'])) {
            $parsedSiteUrl['port'] = 80;
      $port		= ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : '';
      $path		= !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : "";
      $cleanUrl	= "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}";


Is it possible to use this code at \modules\EmailMan\EmailMan.php? I want to opt out of the email address from all SuiteCRM.
Adding this link to under the default remove me link.
Like this;

$mail->Body .= "<br /><span style='font-size:0.8em'>{$mod_strings['TXT_REMOVE_ME']} <a href='" . $this->tracking_url . "index.php?entryPoint=removeme&identifier={$this->getTargetId()}'>{$mod_strings['TXT_REMOVE_ME_CLICK']}</a></span>";