Skip to content

MailerLite PHP SDK Adding HTML Content #19

@codiller

Description

@codiller

Summary

When creating a new campaign using the MailerLite PHP SDK, MailerLite is automatically adding code to the bottom of the HTML content even when the Unsubscribe tag is present in the 'content' parameter being passed to MailerLite API and the "Automatically generate a footer from the company details." is unchecked in the Account Settings. If you edit the HTML content in the MailerLite UX, the code disappears.

Expected Results

A campaign would be created containing only my HTML code that was in the 'content' parameter. In the below example, it is <p>Thanks for the email. <a href="{$unsubscribe}">Unsubscribe</a></p>.

Actual Results

The following code is inserted below the HTML code in the 'content' parameter.

<style type="text/css">
    .mlFooter p{margin:0}@media only screen and (max-width:640px){.mlContentTable{width:100%!important;min-width:10%!important;margin:0!important;float:none!important}.mlContentOuter{padding-bottom:0!important;padding-left:15px!important;padding-right:15px!important;padding-top:0!important}}
</style>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="680" style="width: 680px; min-width: 680px;" class="mlMainContent" dir="ltr">
    <tbody>
        <tr>
            <td class="mlTemplateContainer" style="padding: 20px 20px 0px 20px;">
                <table border="0" cellpadding="0" width="100%" class="mlMainContent" style="border-top: 1px solid #d1d3d3;">
                    <tbody>
                        <tr>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
<table role="article" aria-roledescription="email" align="center" border="0" cellpadding="0" cellspacing="0" width="680" style="width: 680px; min-width: 680px;" class="mlMainContent" dir="ltr">
    <tbody>
        <tr>
            <td class="mlTemplateContainer" style="padding: 20px 20px 0px 20px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mlMainContent">
                    <tbody>
                        <tr>
                            <td style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 125%; color: #000000; padding-top: 15px;" class="ml-rte-footer" align="left">
                            </td>
                        </tr>
                        <tr>
                            <td id="mlRTEfooterUnsubscribe" style="line-height: 125%;" align="left">
                            </td>
                        </tr>
                        <tr>
                            <td height="20"></td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>

Steps to Reproduce

  1. Install MailerLite PHP SDK as shown here: https://github.com/mailerlite/mailerlite-php
  2. Create new php file in the project copying and pasting the example shown here: https://github.com/mailerlite/mailerlite-php#create-campaign
  3. Add any HTML into the 'content' parameter. I added: <p>Thanks for the email. <a href="{$unsubscribe}">Unsubscribe</a></p>
  4. From the command line, run your PHP file to create the campaign.
  5. The campaign should be created in your MailerLite account and, when you preview the created campaign, you should see the extra code inserted. Here's a preview of a campaign I created via the MailerLite PHP SDK: https://preview.mailerlite.io/preview/692096/emails/107481786535118262

For the above steps to reproduce, here's the entirety of my PHP file:

require 'vendor/autoload.php';

use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => '{my API key went here}']);

$data = [
    'type' => 'regular',
    'name' => '{my campaign name went here}',
	'language_id' => 4,
    'emails' => [
        [
            'subject' => '{my subject went here}',
            'from_name' => '{my name went here}',
            'from' => '{my verified email address went here}',
            'content' => '<p>Thanks for the email. <a href="{$unsubscribe}">Unsubscribe</a></p>',
        ]
    ],
    'filter' => [],
];

$response = $mailerLite->campaigns->create($data);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions