News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Recommend to a friend form not submtting

Started by sagaranvekar, February 16, 2023, 13:46:58 PM

Previous topic - Next topic

sagaranvekar

Hi,
Joomla 4.2.7
Virtuemart  4.0.12 10777

In virtuemart settings "Show the Recommend to a friend link" is enabled and it shows an icon. Clicking on it opens a popup with fields 'Your name, Friend's email and comment box'. I have Google recaptcha enabled. So on entering details and submitting the form, it says

Quote0 - Invalid address: (Reply-To):

I have custom template with overrides. So, I switched to 'Cassiopeia' and still shows same error.

However, I do have "Ask a question" enabled too and it works perfectly.

SMTP details are used to send email in Joomla configuration > Server > Mail. And "Send test mail" works fine too.

Any help will be appreciated.

Jumbo!

That means the vendor/shop email address is not valid. Go to VirtueMart Shop settings and check if you have a valid email address for the vendor. 

sagaranvekar

Thanks for your reply @Jumbo!

I can confirm that email address for vendor is correct. Also, as mentioned, Ask a question is working fine. So, I guess the issue is different. Attaching a screenshot.
Shop is in catalog mode.

pinochico

reply to is email which you put inside form
logically you put wrong email :)

But you can use plugin for debug and show for us more info:
https://extensions.joomla.org/browse/new/extension/n3t-debug/
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

sagaranvekar

Quote from: pinochico on February 16, 2023, 18:39:51 PM
reply to is email which you put inside form
logically you put wrong email :)

But you can use  n3t Debug plugin for debug and show for us more info:
https://extensions.joomla.org/browse/new/extension/n3t-debug/

Thanks for your reply @pinochico
I do confirm that its correct email id I am entering. I tried my gmail and other email ids and same error is shown.

Also, I tried installing plugin. However I am not sure if I am using it correctly as plugin documentation page says "Coming Soon".
I enabled Joomla debug and the issue is here (Screenshot attached):
Quote
Invalid address: (Reply-To):
/home/customer/www/mywebsiteurl.com/public_html/staging/libraries/vendor/phpmailer/phpmailer/src/PHPMailer.php:1092

So, I went to that file and on line no. 1092 we have
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

So, I commented out that condition and to my surprise, when I tried again to submit, it worked!
I was not convinced. So, I downloaded virtuemart full installer which comes with Joomla 3.10.11. Installed it and installed sample vm data. Then I updated Joomla to Joomla 4 and then tested again. Now I can confirm that issue is not just with my shop.
Is something to report to Joomla 4 team?

sirius

Hi
just for info
The PHPMailer Class is not up to date in joomla
Joomla use the 6.6.0 but last version is 6.7.1
And the function is a bit different (line 1076)
Code (php) Select
    protected function addOrEnqueueAnAddress($kind, $address, $name)
    {
        $pos = false;
        if ($address !== null) {
            $address = trim($address);

            $pos = strrpos($address, '@');
        }
        if (false === $pos) {
            //At-sign is missing.
            $error_message = sprintf(
                '%s (%s): %s',
                $this->lang('invalid_address'),
                $kind,
                $address
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        if ($name !== null && is_string($name)) {
            $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
        } else {
            $name = '';
        }
J3.10.12 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.12.10777

sagaranvekar

Thanks for your reply @sirius

I am posting this on Joomla forum to check if I get help there.


sagaranvekar

Got help from toivo on Joomla forum on this topic:
https://forum.joomla.org/viewtopic.php?f=814&t=999875

VirtueMart is forwarding a blank or empty email address through Joomla to PHPMailer in the function sendVmMail() in components/com_virtuemart/helpers/shopfunctionsf.php (lines 890 to 918) causing this error.

As explained on Joomla forum, "recommend to a friend" form submits when it is restricted to logged in users however when a guest user submits form, it ends up with error. So, definitely its a bug in Virtuemart.

It will be really great help if anyone suggests any edits in shopfunctionsf.php for this issue.

sagaranvekar

I tried to make changes. So, I made changes in :
components/com_virtuemart/helpers/shopfunctionsf.php  on line no 893 we have if(!$noVendorMail) condition like this:
Quoteif(!$noVendorMail) {
         $replyTo[0] = $view->vendorEmail;
         $replyToName[0] = $view->vendor->vendor_name;
      } else {
         if(isset($view->orderDetails['details']) && isset($view->orderDetails['details']['BT'])) {
            $replyTo[0] = $view->orderDetails['details']['BT']->email;
            $replyToName[0] = $view->orderDetails['details']['BT']->first_name . ' ' . $view->orderDetails['details']['BT']->last_name;
         } else {
            if(is_object($view->user)){
               $replyTo[0] = isset($view->user->email)? $view->user->email:false;
               $replyToName[0] = isset($view->user->name)? $view->user->name:false;
            } else {
               $replyTo[0] = isset($view->user['email'])? $view->user['email']:false;
               $replyToName[0] = isset($view->user['name'])? $view->user['name']:false;
            }
         }
      }


I changed line no 905 to :


Quoteif(!$noVendorMail) {
         $replyTo[0] = $view->vendorEmail;
         $replyToName[0] = $view->vendor->vendor_name;
      } else {
         if(isset($view->orderDetails['details']) && isset($view->orderDetails['details']['BT'])) {
            $replyTo[0] = $view->orderDetails['details']['BT']->email;
            $replyToName[0] = $view->orderDetails['details']['BT']->first_name . ' ' . $view->orderDetails['details']['BT']->last_name;
         } else {
            if(is_object($view->user)){
               $replyTo[0] = isset($view->user->email)? $view->user->email:false;
               $replyToName[0] = isset($view->user->name)? $view->user->name:false;
            } else {
               $config = JFactory::getConfig(); // fetch Joomla Global configuration
               $replyTo[0] = $config->get( 'mailfrom' ); //from Joomla configuration, get 'From Email' (admin email id) and use it as 'reply-to'
               $replyToName[0] = isset($view->user['name'])? $view->user['name']:false;
            }
         }
      }


There is an issue in Virtuemart setting 'reply-to' for guest users. Not sure if this is correct way, but as no one responded here, I am using this until VM fixes this.

pinochico

logically - the Reply-to function should work as a checkbox for the Refer a Friend function (where I insert a friend's email) - send a copy of the email to myself or to a friend's email.

So I don't understand why there is an email from Joomla configuration.

However, I consider the Reply-to function rather a constant source of SPAM problems, I don't know if VM has an email existence check function for the Recommend to Friend function, personally I would prefer not to use it (we also disable it for normal Joomla forms).

Translated with www.DeepL.com/Translator (free version)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

sirius

@sagaranvekar
Looks good to me, let's see what others say about it.

Quote from: just for infoWhen you send an email to a subscriber and they click 'Reply', the reply message is typically sent to the email address listed in the From: header.

A Reply-To address is identified by inserting the Reply-To header in your email. It is the email address that the reply message is sent when you want the reply to go to an email address that is different than the From: address.
J3.10.12 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.12.10777

sagaranvekar

Quote from: pinochico on February 20, 2023, 16:00:59 PM
logically - the Reply-to function should work as a checkbox for the Refer a Friend function (where I insert a friend's email) - send a copy of the email to myself or to a friend's email.

So I don't understand why there is an email from Joomla configuration.

However, I consider the Reply-to function rather a constant source of SPAM problems, I don't know if VM has an email existence check function for the Recommend to Friend function, personally I would prefer not to use it (we also disable it for normal Joomla forms).

Translated with www.DeepL.com/Translator (free version)

Thanks for your reply @pinochico

If you check recommend to a friend form, it has fields your name, friend's email and comment. No option to enter email id of sender. So, lets say I am sending it to my friend and I entered friend's email id. What is the point in setting reply-to field to friend's email id? And as my shop is in catalog mode, user cannot login. So, user's email id will not be fetched. So, ideally, reply-to needs to be set to vendor's email id or joomla admin's email id. I am using SMTP, so I chose to use Joomla admin's email id from config.

Virtuemart does same thing. You can find this code in shopfunctionsf.php around line no 935
if(empty($sender[0])){
$config = JFactory::getConfig();
$sender = array( $config->get( 'mailfrom' ), $config->get( 'fromname' ) );
}

dudley389

Just loaded the latest version of Joomla4 and VM and the issue is still their.!!!

Is there going to be a fix for this soon,.!

Thanks