Last active
April 19, 2024 11:49
-
-
Save calevans/4ddeea461a4bd59a45bc1ed3f1dad572 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use FluentCrm\App\Models\Campaign; | |
use FluentCrm\Framework\Database\Orm; | |
use FluentCrm\App\Models\Lists; | |
use FluentCrm\App\Services\CampaignProcessor; | |
$listName = 'scuba-news-list'; | |
$listApi = FluentCrmApi('lists'); | |
$list = $listApi->get()->where('slug',$listName)->first(); | |
$campaign = Campaign::create( | |
[ | |
'email_subject'=>'Test Subject ' . date('Y-m-d H:i:s'), | |
'email_body'=>'This is the body of the email.', | |
'type'=>'campaign', | |
'status' => 'scheduled', | |
'scheduled_at' => date('Y-m-d H:i:s'), | |
'title' => 'Test Title ' . date('Y-m-d H:i:s'), | |
'template_id' => 0, | |
'settings' => [], | |
] | |
); | |
$campaign->status = 'processing'; | |
$settings = $campaign->settings; | |
$settings['subscribers'] = [0=>['list'=>$list->id,'tag'=>'all']]; | |
$campaign->setSettingsAttribute($settings); | |
$campaign->save(); | |
$processor = new CampaignProcessor($campaign->id); | |
$processedCampaign = $processor->processEmails(30, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment