Magento 1.9 new shipment email body blank when sending programatically

Job ID: 34178544

Budget: $10 – $30 USD

This is a small issue Looking for quick fix on this.

When submitting from admin panel manually -- Shipment emails are working fine

When adding tracking information from an external source (Shiprocket API) - Shipment emails body is coming as blank, email subject is coming fine. Shipment tracking details are also submitted on magento with no issues.

Here is the code

$shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentId);

if(!$shipment->getEmailSent())
{
$shipment->sendEmail();
$shipment->setEmailSent(true);
$shipment->save();
}

Possible reasons:
exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent
The issue maybe It is outputting some text before calling the email sending block which was causing the error of headers not being sent.
Or
email template may not be supporting links in emails when sending via API

This could be due to retrieving the tracking info by sending a POST request to an API. What could I do to resolve the headers issue ?
Related categories: PHP Linux Magento Zend MySQL