I'm trying to get the email address in the email sent from Sales > Orders > Send Email.

I use this code and it works as long as the customer in making an order:

$websiteId = Mage::app()->getWebsite()->getId();
$email = Mage::getSingleton('checkout/session')->getQuote()->getCustomerEmail();
$encoded = base64_encode($email);

But when I send the email from Admin in Sales > Orders > Send Email the above code fails to work.

How can I get something that will work basically everywhere?



1 Answer 1


I'm not sure what context you wish to run your code in, but you shouldn't be using the checkout session model to get a customer email in the admin. Instead, you should get it from the order model rather than the quote model, eg:

$email = $this->getOrder()->getCustomerEmail();
  • use this code $email = $quote->getBillingAddress()->getEmail(); if (!$email) $email = $quote->getCustomerEmail();
    – Vishal
    Jul 29, 2016 at 11:15
  • @Robbie that code didn't work. I'm using it the order confirmation emails, but I would like to find something that would work in all the templates.
    – Freejoy
    Jul 29, 2016 at 11:40
  • @MagikVishal Your code took out my store! : ) Really thou it caused an error: Call to a member function getBillingAddress() on null
    – Freejoy
    Jul 29, 2016 at 11:42
  • @Freejoy this should work from any admin order abstract block. If you want to get an order from somewhere else in admin you'll need to be more specific in your question.
    – scrowler
    Jul 29, 2016 at 11:45
  • Okay I'm trying to create an auto login using the customer's email address in the url. As far as that it works. I want to encode the url so the customer can't see it in their url. I would like it to work from the admin orders section too. I guess it would be okay the way it is but what is so hard about getting it to work in the admin orders section. I've tried everything on Google.
    – Freejoy
    Jul 29, 2016 at 11:53

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.