To send an email to all subscribers of your list, you must create a campaign.
A campaign can be created like this:
->subject('My newsletter #1')
trackClicks calls are optional.
Alternatively, you could manually set the attributes on a
'from_email' => 'email@example.com',
'subject' => 'My newsletter #1',
'content' => $html,
'track_opens' => true,
'track_clicks' => true,
'email_list_id' => $emailList->id,
Setting the content and using placeholders
You can set the content of a campaign by setting it's
$campaign->html = $yourHtml;
In that HTML you can use these placeholders which will be replaced when sending out the campaign:
::unsubscribeUrl::: this string will be replaced with the URL that, when hit, will immediately unsubscribe the person that clicked it
::webviewUrl: this string will be replaced with the URL that will display the content of your campaign. Learn more about this in the docs on webviews.
If there is no way for a subscriber to unsubscribe, it will result in a lot of frustration on the part of the subscriber. We recommend always to use the
::unsubscribeUrl:: in the HTML of each campaign you send.
Setting a from name
To set a from name, just pass the name as a second parameter to
Campaign::create()->from('firstname.lastname@example.org', 'Sender name')
Setting a reply to
Optionally, you can set a reply to email and name like this
Campaign::create()->replyTo('email@example.com', 'John Doe')