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>
  • If you want to retrieve selected emails from this above code drop down then place all system.xml code – Aman Alam Jun 25 '16 at 6:44
  • Thank for your reply Aman Alam. but i dont know. Please mention system.xml code here – Sathiyabama Jun 25 '16 at 7:00
15

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');
  • i created own module, there how to get sender name and email ? – Sathiyabama Jun 25 '16 at 6:52
  • paste your all code of system.xml – Aman Alam Jun 25 '16 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 Jun 25 '16 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 Jun 25 '16 at 7:10
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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