7

enter image description hereI created own module, there how to get sender name and email ?

I have to create custom admin config option like Email Sender. Here i used below code, to set drop-down then i don't know how to get store email and name in my controller.

<outofstocknotification_admin_email>
    <label>Email Sender</label>
    <frontend_type>select</frontend_type>
    <source_model>adminhtml/system_config_source_email_identity</source_model>
</outofstocknotification_admin_email>
2
  • If you want to retrieve selected emails from this above code drop down then place all system.xml code
    – Aman Alam
    Commented Jun 25, 2016 at 6:44
  • Thank for your reply Aman Alam. but i dont know. Please mention system.xml code here Commented Jun 25, 2016 at 7:00

4 Answers 4

19

To retrive store sender name and email address :

General Contact

    /* Sender Name */
    Mage::getStoreConfig('trans_email/ident_general/name'); 
    /* Sender Email */
    Mage::getStoreConfig('trans_email/ident_general/email');

Sales Representative

    /* Sender Name */
    Mage::getStoreConfig('trans_email/ident_sales/name'); 
    /* Sender Email */
    Mage::getStoreConfig('trans_email/ident_sales/email');

Customer Support

    /* Sender Name */
    Mage::getStoreConfig('trans_email/ident_support/name'); 
    /* Sender Email */
    Mage::getStoreConfig('trans_email/ident_support/email');

Custom Email 1

    /* Sender Name */
    Mage::getStoreConfig('trans_email/ident_custom1/name'); 
    /* Sender Email */
    Mage::getStoreConfig('trans_email/ident_custom1/email');

Custom Email 2

    /* Sender Name */
    Mage::getStoreConfig('trans_email/ident_custom2/name'); 
    /* Sender Email */
    Mage::getStoreConfig('trans_email/ident_custom2/email');
4
  • i created own module, there how to get sender name and email ? Commented Jun 25, 2016 at 6:52
  • paste your all code of system.xml
    – Aman Alam
    Commented Jun 25, 2016 at 6:58
  • 2
    Store emails are unique if you need to use same don't need to replicate store email you can use above mentioned code to retrieve store emails if you need your own to set different email then you need to create fields for sender email and sender name and you able to retrieve each field by calling store config Mage::getStoreConfig(<section name>/<group name>/<field name>');
    – Aman Alam
    Commented Jun 25, 2016 at 7:07
  • 2
    As i seen your screen shot seems your are in need to retrieve general contact email value from your module it work same as suggested you should Mage::getStoreConfig(<section name>/<group name>/outofstocknotification_admin_email'); update your section name and group name i only seen your field name so i have added that.
    – Aman Alam
    Commented Jun 25, 2016 at 7:10
2

You can retrieve store email address and store name in your module using the follow code

General Contact details

Get Sender Name

Mage::getStoreConfig('trans_email/ident_general/name');

Get Sender Email

Mage::getStoreConfig('trans_email/ident_general/email');

Reference source: https://magentoexplorer.com/get-magento-store-email-address-programmatically

0
$sender = Mage::getStoreConfig('<section_name>/<group_name>/outofstocknotification_admin_email');
$name = Mage::getStoreConfig('trans_email/ident_'.$sender.'/name');
$email = Mage::getStoreConfig('trans_email/ident_'.$sender.'/email');

This way you get the Name and Email of the store, according to your module choice.

0

I made a custom extension for this. I've committed it to GitHub for anyone to use or take inspiration from.

https://github.com/henryhayes/HenryHayes_Contacts

Options are:

const CONTACT_GENRAL    = 'general';
const CONTACT_SALES     = 'sales';
const CONTACT_SUPPORT   = 'support';
const CONTACT_CUSTOM1   = 'custom1';
const CONTACT_CUSTOM2   = 'custom2';

Example use:

Mage::helper('henryahyes_contacts')->getContatName(HenryHayes_Contacts_Helper_Data::CONTACT_GENRAL);
Mage::helper('henryahyes_contacts')->getContatEmail(HenryHayes_Contacts_Helper_Data::CONTACT_GENRAL);
Mage::helper('henryahyes_contacts')->getContatName('general');
Mage::helper('henryahyes_contacts')->getContatEmail('general');

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.