Snippets with the tag: email

Unsubscribe customer using email address

Description

Unsubscribe customer from the newsletter using the email address

Code

Mage::getModel('newsletter/subscriber') 
->loadByEmail($emailAddress) 
->unsubscribe();

Display store contact name and email

Description

Display store contact name and email

Code

// 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');

Sending transactional emails

Description

Sending transactional emails

Code

$email = Mage::getModel('core/email_template');

$email->sendTransactional(
    'some_email_template',                                                 // template
    array('name' => 'Your Company', 'email' => 'contact@yourcompany.com'), // sender details
    'joe@joebloggs.com',                                                   // recipient email
    'Joe Bloggs',                                                          // recipient name
    array('customerName' => 'Joe Bloggs'),                                 // merge vars
    Mage::app()->getStore()->getStoreId()                                  // store id
);