0

I'm using this code to send an email in Magento.

public function send()
    {
        $config = array('ssl' => 'tls',
        'port' => 587,
        'auth' => 'login',
        'username' => '[ME]@gmail.com',
        'password' => '[PASS]');

        $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

        if (Mage::getStoreConfigFlag('system/smtp/disable')) {
            return $this;
        }

        $mail = new Zend_Mail();

        if (strtolower($this->getType()) == 'html') {
            $mail->setBodyHtml($this->getBody());
        }
        else {
            $mail->setBodyText($this->getBody());
        }

        $mail->setFrom($this->getFromEmail(), $this->getFromName())
            ->addTo($this->getToEmail(), $this->getToName())
            ->setSubject($this->getSubject());
        $mail->send($transport);

        return $this;
    }

This works fine, but, the people who receive the email can see that it's sended by: [ME]@gmail.com how can I change this in the Zend mailer?

3

This line:

$mail->setFrom($this->getFromEmail(), $this->getFromName())

Sets the from email and the name from class methods getFromEmail and getFromName - which are likely returning your [me]@gmail.com address. If this is a core method, this is configurable within the admin panel System > Config > Sales Emails:

enter image description here

If this is custom code, you should fill in your desired values in the setFrom method:

$mail->setFrom('[me]@storedomain.com', 'Store Name')

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.