I have a bootstrap script that is used to mark orders as shipped. After shipping the order it used ShipmentNotifier to send out the shipment email. Despite Debugging Hints being turned off everywhere, the email that it sends still includes the red path hints.

I have tried setting the script to run in the 'frontend' state instead of 'adminhtml', but it makes no difference, the red boxes remain.

If I send the email out manually using the Magento backend then it sends correctly (no debug hints). This leaves me to believe there is something I am missing in the bootstrap script.

Has anyone encountered this issue before? What did you do to resolve it?

// Register shipment

            // Save created shipment and order
        catch (\Exception $e) 
            echo "<font color=red><b>EXCEPTION: </b></font>". $e->getMessage(); exit;

        //send email
        $shipmentNotifier = $objectManager->create('Magento\Shipping\Model\ShipmentNotifier');

Screenshot of Email

1 Answer 1


I could solve this the following way

public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager,
                            \Magento\Framework\ObjectManagerInterface $objectManager,
                            \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader,
                            \Magento\Framework\App\AreaList $areaList) {

        $this->storeManager = $storeManager;
        $this->objectManager = $objectManager;
        $this->configLoader = $configLoader;
        $this->areaList = $areaList;



public function init() {


        $localeInterface = $this->objectManager->create('Magento\Framework\TranslateInterface');

        $areaObject = $this->areaList->getArea(\Magento\Framework\App\Area::AREA_ADMINHTML);


My problem was that i had the email debug path inside the mails. This is caused by magento itself, because magento won´t set any store view or load languages or translations in a cron / command. So you need to set it by yourself.

We have 1 location of sending an email - when creating a shipment - and here it works like a charm. The email looks - like it should - the same like if i would create a shipment in the backend manually.

It is a shame for magento that there is no "preloading" of translations, store views or helper functions for commands, like setting the language / store view.

You are not the only one with the problem, i have seen much more threads. And nobody could help, which is very unusual for Magento. I hope I could help you further :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.