magepal / magento2-gmail-smtp-app

Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
https://www.magepal.com
319 stars 148 forks source link

Emails not working but get success message when trying to send a test email #157

Closed nafees1988 closed 4 years ago

nafees1988 commented 4 years ago

Magento version #:

Edition (EE, CE, OS, etc):

Expected behavior:

Actual behavior:

Steps to reproduce:

Preconditions

nafees1988 commented 4 years ago

We have installed MagePal SMTP extension and it was working fine, now when we test it by sending a test email it shows the success message but not receiving the email also no other emails working on our magento 2 sotre. Can you please advise on what can be the issue?

Emails working when we disable the extension.

MohanaKVS commented 4 years ago

Hi, When i disable this module i'm getting "Unable to send mail: Unknown error" when submit any contact form. Please advice me.

Thanks

srenon commented 4 years ago

Since I have zero information on what version of our extension you are using or what version of Magento you are using it is next to impossible to even try to offer help.

You will need to do some debugging, that error message seems to trigger from vendor/zendframework/zend-mail/src/Transport/Sendmail.php line 290

MohanaKVS commented 4 years ago

Hi, I'm using magento 2.3.3 and MagePal_GmailSmtpApp v2.6.8. Can you please advice ASAP, because my website is on live.

Jacksonberrystorm commented 1 year ago

Hello. I have a query. We have installed MagePal SMTP extension and it was working fine, now when we test it by sending a test email it shows the success message and Test Message has been transported. So I had maken other email template and I had tried custom email action. But not receiving the email. At that time success send message is shown in Magento Admin Page. If I had checked gmail, but mail was not come in. I am going to send my custom email. Server setting is follow.

image

Controller/EmailAction.php

  public function execute()
          {
              $data = $this->getRequest()->getParams(); 
              $this->customerRepository = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Customer\Api\CustomerRepositoryInterface');

              $this->transportBuilder = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\Mail\Template\TransportBuilder');

             $this->scopeConfig = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\Config\ScopeConfigInterface');

           $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Store\Model\StoreManagerInterface');

        $this->inlineTranslation = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\Translate\Inline\StateInterface');    

        if ($data) {
            try {
                //get template by id
                $objectManager = \Magento\Framework\App\ObjectManager::getInstance()->create('Magento\Email\Model\Template');
                $template = $objectManager->load($data['template_id'])->toArray();

                // get order
                $collection = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Sales\Model\ResourceModel\Order\CollectionFactory')->create();
                $collection->getSelect()->where('main_table.entity_id ='.$data['order_id']);
                $order = $collection->load()->toArray()['items'][0];
                //get order_meisai
                $order_meisai = $this->getOrderProductInfo($this->_getProduct($data['order_id']));
                // get sender
                $collection = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\User\Model\ResourceModel\User\CollectionFactory')->create();
                $collection->getSelect()->where('main_table.user_id ='.$data['sender']);
                $user = $collection->load()->toArray()['items'][0];
                // get customer
                $customer = $this->customerRepository->getById($data['customer_id']);
                $templateParams = 
                    [
                        'customer_name' => $data['customer_name'],
                        'order_num' => $order['increment_id'],
                        'order_meisai' => $order_meisai,
                    ];

                $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
                $this->inlineTranslation->suspend();
                $transport = $this->transportBuilder
                    ->setTemplateIdentifier(
                        $template['orig_template_code']
                    )
                    ->setTemplateOptions(
                        [
                            'area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 
                            'store' => $this->storeManager->getStore()->getId(),
                        ])
                    ->setTemplateVars($templateParams)
                    ->setFrom(
                        [
                            'name' => $user['username'], 
                            'email' => $user['email']
                        ])
                    ->addTo($customer->getEmail())
                    ->getTransport();
                $transport->sendMessage();
                $this->inlineTranslation->resume();
                $this->messageManager->addSuccess(__('Success send mail.'));
            } catch (\Exception $e) {
                $this->messageManager->addException($e, __('We can\'t send mail now.'));
                $this->_redirect('**************', ['order_id' => $data['order_id']]);
                return;
            }
        }
        $this->_redirect('*************', ['order_id' => $data['order_id']]);
    }

If I have run above code, then Success send mail message is shown but if I check gmail, the mail hasn't come in. Magento version is 2.4.5 and MagePal SMTP extension version is v2.9.0 .

Can you please advise on what can be the issue?