質問

このコードを使用して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;
    }

これは正常に動作しますが、メールを受け取った人は、次のことによって送信されていることがわかります。

役に立ちましたか?

解決

この行:

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

From EmailとClassメソッドからの名前を設定します getFromEmailgetFromName - おそらくあなたを返しています [me]@gmail.com 住所。これがコアメソッドの場合、これは管理パネル内で構成可能です システム> config>販売メール:

enter image description here

これがカスタムコードの場合、セットフロムメソッドで目的の値を入力する必要があります。

$mail->setFrom('[me]@storedomain.com', 'Store Name')
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top