cc function existed in zend_mail class in lib folder.
public function addCc($email, $name='')
{
if (!is_array($email)) {
$email = array($name => $email);
}
foreach ($email as $n => $recipient) {
$this->_addRecipientAndHeader('Cc', $recipient, is_int($n) ? '' : $n);
}
return $this;
}
For now i just edited core files.but we need to override to our local/community folder.I have created 2 arrays & 4 new functions for cc in info.php
<?php
class Mage_Core_Model_Email_Info extends Varien_Object
{
/**
* Name list of "Bcc" recipients
*
* @var array
*/
protected $_bccNames = array();
protected $_ccNames=array();
/**
* Email list of "Bcc" recipients
*
* @var array
*/
protected $_bccEmails = array();
protected $_ccEmails = array();
/**
* Name list of "To" recipients
*
* @var array
*/
protected $_toNames = array();
/**
* Email list of "To" recipients
*
* @var array
*/
protected $_toEmails = array();
/**
* Add new "Bcc" recipient to current email
*
* @param string $email
* @param string|null $name
* @return Mage_Core_Model_Email_Info
*/
public function addBcc($email, $name = null)
{
array_push($this->_bccNames, $name);
array_push($this->_bccEmails, $email);
return $this;
}
public function addCc($email, $name = null)
{
array_push($this->_ccNames, $name);
array_push($this->_ccEmails, $email);
return $this;
}
/**
* Add new "To" recipient to current email
*
* @param string $email
* @param string|null $name
* @return Mage_Core_Model_Email_Info
*/
public function addTo($email, $name = null)
{
array_push($this->_toNames, $name);
array_push($this->_toEmails, $email);
return $this;
}
/**
* Get the name list of "Bcc" recipients
*
* @return array
*/
public function getBccNames()
{
return $this->_bccNames;
}
/**
* Get the email list of "Bcc" recipients
*
* @return array
*/
public function getBccEmails()
{
return $this->_bccEmails;
}
/**
* Get the name list of "cc" recipients
*
* @return array
*/
public function getccNames()
{
return $this->_ccNames;
}
/**
* Get the email list of "Bcc" recipients
*
* @return array
*/
public function getccEmails()
{
return $this->_ccEmails;
}
/**
* Get the name list of "To" recipients
*
* @return array
*/
public function getToNames()
{
return $this->_toNames;
}
/**
* Get the email list of "To" recipients
*
* @return array
*/
public function getToEmails()
{
return $this->_toEmails;
}
}
In Mage_Core_Model_Email_Template_Mailer
public function send()
{
$emailTemplate = Mage::getModel('core/email_template');
// Send all emails from corresponding list
while (!empty($this->_emailInfos)) {
$emailInfo = array_pop($this->_emailInfos);
// Handle "Bcc" recepients of the current email
$emailTemplate->addBcc($emailInfo->getBccEmails());
$emailTemplate->addCc($emailInfo->getccEmails());
// Set required design parameters and delegate email sending to Mage_Core_Model_Email_Template
$emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
->sendTransactional(
$this->getTemplateId(),
$this->getSender(),
$emailInfo->getToEmails(),
$emailInfo->getToNames(),
$this->getTemplateParams(),
$this->getStoreId()
);
}
return $this;
}
add this function in Mage_Core_Model_Email_Template
public function addCc($cc)
{
if (is_array($cc)) {
foreach ($cc as $email) {
$this->getMail()->addCc($email);
}
}
elseif ($cc) {
$this->getMail()->addCc($cc);
}
return $this;
}
In Helloworld/Custom/Model/Observer.php
file, i think you need change
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
){
$this->_scopeConfig = $scopeConfig;
$this->_transportBuilder = $transportBuilder;
$this->inlineTranslation = $inlineTranslation;
}
public function execute(\Magento\Framework\Event\Observer $observer){
$this->inlineTranslation->suspend();
//return template id(custom_mail_template) setup in Configuration
$emailtemplate = $this->_scopeConfig->getValue('custom_mail_template',\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$transport = $this->_transportBuilder->setTemplateIdentifier($emailtemplate)->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'store' => $this->_storeManager->getStore()->getId(),
]
)->setTemplateVars(
[
'store' => $this->_storeManager->getStore(),
'store URL' => $prodUrl
]
)->setFrom(
[
'email' => 'dotnet@gmail.com',
'name' => 'Store Owner'
]
)->addTo(
'training@gmail.com',
'Training'
)->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
}
And rename: Helloworld/Custom/etc/email_template.xml
to Helloworld/Custom/etc/email_templates.xml
I hope it help you.
Best Answer
This is new as of Magento CE 1.9.1.0. The password is no longer stored in plain text, but stored encrypted into the database (security reasons). Therefore the space behind the password in the confirmation email is blank. I guess the Magento Core Team forgot to remove this from the email templates.
You could remove the password label from the email template entirely or change the email template to something like this:
Password: The password you used to create your account
Also refer to this question and my answer.