title: Magento: Email stuck in queue? 'This letter cannot be sent.'
body: <p>Something strange is going on with my Magento install. Everything with the emails used to work fine, but now I have these messages in my exception.log:</p>
  
  <pre><code>2015-05-11T10:00:02+00:00 ERR (3):
  exception 'Exception' with message 'This letter cannot be sent.' in /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/core/Mage/Core/Model/Email/Template.php:399
  Stack trace:
  #0 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php(24): Mage_Core_Model_Email_Template-&gt;send('info@mysite.de', 'mysite', Array)
  #1 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/community/Hackathon/MageMonitoring/Model/WatchDog/UberDog.php(108): Ebizmarts_Mandrill_Model_Email_Template-&gt;send('info@mysite.de', 'mysite', Array)
  #2 [internal function]: Hackathon_MageMonitoring_Model_WatchDog_UberDog-&gt;triggerActiveDogs(Object(Mage_Cron_Model_Schedule))
  #3 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/core/Mage/Cron/Model/Observer.php(325): call_user_func_array(Array, Array)
  #4 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/core/Mage/Cron/Model/Observer.php(72): Mage_Cron_Model_Observer-&gt;_processJob(Object(Mage_Cron_Model_Schedule), Object(Mage_Core_Model_Config_Element))
  #5 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1338): Mage_Cron_Model_Observer-&gt;dispatch(Object(Varien_Event_Observer))
  #6 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App-&gt;_callObserverMethod(Object(Mage_Cron_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
  #7 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/app/Mage.php(448): Mage_Core_Model_App-&gt;dispatchEvent('default', Array)
  #8 /var/www/vhosts/lvps91-250-119-53.dedicated.hosteurope.de/httpdocs/magento/cron.php(76): Mage::dispatchEvent('default')
  #9 {main}
  </code></pre>
  
  <p>This is written to the log files every 5 minutes so I guess it must be the cronjob trying to send out mail and failing.</p>
  
  <p>I tried tracking the problem and it was caused by this function in Template.php to return false: </p>
  
  <pre><code>$this-&gt;isValidForSend()
  </code></pre>
  
  <p>So following <a href="https://stackoverflow.com/questions/9393220/magento-not-sending-out-any-mails-how-to-debug">this</a> advice I added this line to the function to figure out why it would return false. It just writes the results of isValidForSend to an email.log file.</p>
  
  <pre><code>Mage::Log(var_export(!Mage::getStoreConfigFlag('system/smtp/disable'),true).';'.var_export($this-&gt;getSenderName(),true).';'.var_export($this-&gt;getSenderEmail(),true).';'.var_export($this-&gt;getTemplateSubject(),true),null,'email.log');
  </code></pre>
  
  <p>The results from email.log:</p>
  
  <pre><code>2015-05-11T08:35:02+00:00 DEBUG (7): true;'MACHIMA';'info@mysite.de';NULL
  2015-05-11T08:40:02+00:00 DEBUG (7): true;'MACHIMA';'info@mysite.de';NULL
  2015-05-11T08:45:02+00:00 DEBUG (7): true;'MACHIMA';'info@mysite.de';NULL
  2015-05-11T08:50:02+00:00 DEBUG (7): true;'MACHIMA';'info@mysite.de';NULL
  </code></pre>
  
  <p>So everything seems to be ok, just the last NULL value which is returned by </p>
  
  <pre><code>$this-&gt;getTemplateSubject() 
  </code></pre>
  
  <p>causes the function to fail. </p>
  
  <p>I checked the configuration about 10 times and don't find any emails that are being sent out and are missing a subject. </p>
  
  <p>My thought now is that maybe there is an email stuck in a queue Magento keeps trying to send out every 5 minutes.</p>
  
  <p>Is there a way to track down where this is coming from?</p>
  
  <p>Thanks</p>