There are two things to consider here:
- How to approach sending to a list
- How to approach populating a notification with dynamic information
Sending email to a list of users
Sprout Email notifications use the default Craft email service. Each notification is sent to a single individual. To send to a list, what you'll need to do behind the scenes is loop through all the people in that list and send them each an email one by one.
Sending notifications with dynamic information
While Sprout Email uses the default email sending behavior in Craft, to send notifications programmatically you'll want to use the
$campaign variable should be an instance of a
SproutEmail_CampaignModel and can be created by retrieving the Notification you want to send by it's ID like so:
$object is the data that will be processed in your template and any fields that accept dynamic variables such as the Subject, From Name, From Email, Reply To, and Recipients fields.
In your situation, it sounds like you are sending User-specific notifications and your template might be expecting a
UserModel for any dynamic variables.
A very rough starting point for how to approach the sending could be as follows:
// Get all your users first
foreach ($users as $user)
// Get your Campaign (SproutEmail_CampaignModel)
$campaign = craft()->sproutEmail_notifications->getNotificationById($campaignId);
// Get your User (UserModel)
// This step is only needed if $user is not already a UserModel
$user = craft()->users->getUserById($userId);
// Send your Notification