Asked  7 Months ago    Answers:  5   Viewed   23 times

Ok so I'm looking to send out a weekly scheduled email with MailChimp. The email is to contain the newest 20 of the stock list (car stocklist of garage) to their subscribers.

I can't seem to get this to work with an RSS feed as imagined so i wondered is there any other way to get some formatted HTML (in a PHP file) into the body of MailChimp template on a weekly basis?

Many thanks.



If looking to inject custom content into a template at the time of sending, I would recommend having a look into creating a custom template that uses our template language.

If you've created a custom template within MailChimp using our template language to specify editable content areas:, then you would be able to update those content areas via the API.

To do this, you'll want to make either a campaigns/create call: or a campaigns/update call: and specify the section and content that you'd like to change as part of the 'content' parameter. the content 'sections' will correspond to the mc:edit tags that were added to the custom template.

You also have the ability to customize your content, like adding a first name to a greeting in the body of your content for instance, even further with the use of merge tags. I highly recommend checking those out as well and consider using them in your content if you need that level of customization: Getting Started with Merge Tags:

Wednesday, March 31, 2021
answered 7 Months ago

Your code looks fairly straightforward and syntactically correct. Is the script returning any error messages?

If you're receiving the message without any issues, then the problem doesn't look to be in your code.

A few things to check:

  • Make sure that the file "matt.txt" is both readable by your webserver and that the path is correct. The path to the file needs to be included in the $mail->AddAttachment() method call and should be relative to the script's location.
  • Verify that your mail server isn't stripping any attachments out due to restrictions and/or try sending a different attachment file type (try a .zip or a .jpg file)
  • If you're running a newer version of phpMailer, you can try catching any exceptions that are thrown (perhaps one that isn't preventing the message from going out, but just preventing the attachment from being included) using the following syntax: (taken from phpMailer Example Code)

    require 'PHPMailer/PHPMailerAutoload.php';
    $mail = new PHPMailer(true);
    try {
      $mail->IsSMTP();    // set mailer to use SMTP
      $mail->Host = "";    
      $mail->From = "";    
      $mail->FromName = "HCSC";  
      $mail->AddAddress("", "Example"); 
      $mail->AddReplyTo("", "Hcsc"); 
      $mail->WordWrap = 50;    
      $mail->Subject = "AuthSMTP Test";
      $mail->Body    = "AuthSMTP Test Message!";
      echo "Message Sent OK<p></p>n";
    } catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
Saturday, May 29, 2021
answered 5 Months ago

Drop the mail() function in favor of PHPMailer. It is way more flexible, is object oriented, much easier to configure with SMTP and has much better attachments support (if you need it).

To send your email in phpmailer you'll just need something like this to set your SMTP:

$mailer = new PHPMailer();
$mailer->Mailer = 'smtp';
$mailer->Host = '123.456.789.012';
$mailer->From = '';
$mailer->FromName = 'Me Myself';
$mailer->AddAddress = '';
$mailer->Subject = 'My subject line';
$mailer->Body = 'Your Body text here, in HTML if you set $mailer->IsHtml(true)';
Saturday, May 29, 2021
answered 5 Months ago
app.controller('MainCtrl', function($scope,$compile) {

    var btnhtml = '<button type="button" ng-click="addButton()">Click Me</button>';
    var temp = $compile(btnhtml)($scope);

    //Let's say you have element with id 'foo' in which you want to create a button

   var addButton = function(){
       alert('Yes Click working at dynamically added element');


you need to add $compile service here, that will bind the angular directives like ng-click to your controller scope. and dont forget to add $compile dependency in your controller as well like below.

here is the plunker demo

Wednesday, June 30, 2021
answered 4 Months ago

I struggled with this for a few days, using the template manager in MailChimp. The only way I got it to work was exporting my existing template, adding the mc:edit tag to the code and then uploading it as a custom template.

Exporting template from MailChimp

  • Go to 'Templates'
  • Click on the 'Edit' drop down arrow, next to the template you want to use with the API
  • Select 'Export HTML'

Uploading your template to MailChimp

  • Go to 'Templates'
  • Click the 'Create Template ' button in the top right
  • Click the 'Code Your Own'
  • Then select 'Import html'

Example of my template code:

<div mc:edit="eventmessage">
Custom Event Message (replaced by API Call)

As a check, I was now able to see the section now appear when using /templates/info API call

Once I confirmed that Mailchimp saw the template section I used /campaigns/create call, as mentioned above but skipping over the html definition.

Updated campaign/create (content/sections):

"content": {
    "sections": {
        "eventmessage": "Event Message Content"

Tuesday, August 3, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :