문제

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?

도움이 되었습니까?

해결책

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')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top