PHP Magento Tips

How to Get Store Email Addresses in Magento

Rate this posting:
{[['']]}

In Magento, When you are working with Custom module then sometimes your sendTransactional function not sending mail properly. This is because of you are not fetching correct value of Store Contacts Email Addresses Values.

You can fetch correct value of Store Contacts Email Addresses as per below:

// General Contact
$name =  Mage::getStoreConfig('trans_email/ident_general/name'); 
$email = Mage::getStoreConfig('trans_email/ident_general/email');

// Sales Representative
$name =  Mage::getStoreConfig('trans_email/ident_sales/name'); 
$email = Mage::getStoreConfig('trans_email/ident_sales/email');

// Customer Support
$name =  Mage::getStoreConfig('trans_email/ident_support/name'); 
$email = Mage::getStoreConfig('trans_email/ident_support/email');

// Custom Email 1
$name =  Mage::getStoreConfig('trans_email/ident_custom1/name'); 
$email = Mage::getStoreConfig('trans_email/ident_custom1/email');

// Custom Email 2
$name =  Mage::getStoreConfig('trans_email/ident_custom2/name'); 
$email = Mage::getStoreConfig('trans_email/ident_custom2/email'); 

Or Even more better:


From selection drop down list of Store Contacts Email Address <source_model>adminhtml/system_config_source_email_identity</source_model> you can get name of the store contact person and finally its Email from below code:

$email_id = Mage::getStoreConfig('trans_email/ident_'.$mail.'/email');
Where $mail is the value of your field which you can get from Mage::getStoreConfig(sections/groups/fields)

Additionally, you can also get your store name, Phone number and address from below code.

Name:

Mage::getStoreConfig('general/store_information/name');

Phone number:

Mage::getStoreConfig('general/store_information/phone');

Address:

Mage::getStoreConfig('general/store_information/address');

You have to add your store information in System >> Configuration >> General >> General >> Store Information

Tag : Magento
0 Comments On "How to Get Store Email Addresses in Magento"

Back To Top