Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Important information for almost every question:
V1: Which Visforms version is running?
V2: Which Joomla version is running?
V3: Which PHP version is running?

"Could not instantiate mail function" message PHP mailwithout FILE UPLOAD field

More
6 years 9 months ago #5190 by ceesborst
I have several VI-Forms without any problems. All forms had a FILE UPLOAD field. With PHP mailer or SMTP mailer I always got result and recipient e-mails.

The problem came with a new form without a FILE UPLOAD field. With PHP mailer I only get recipient e-mails and no result e-mails when I use e-mails in the e-mail field with HOTMAIL or GMAIL e-mailadresses. When I use an e-mailaddress of my local provider, i.e. KPN in The Netherlands, I do get result e-mails and recipient e-mails with PHP mailer in the Joomla global configuration. .

A form without a FILE UPLOAD field works fine when I use SMTP mail in the Global Configuration, so I do receive result and recipient e-mails for HOTMAIL, GMAIL and my locaL provider e-mails. The problem with SMTP is that in the result and recipient e-mails the FROM name is my GMAIL user name and GMAIL e-mailaddress which I have defined in the Global Configuration to get access to the GMAIL SMTP mailer.
I wonder why with SMTP the FROM Name and FROM E-mail fields are not used form the Global Configuration. These fields are used with PHP mail function.

After many tests I figured out that the mail failures with PHP mail do occur when there is no FILE UPLOAD field filled with a filename. It only works when the FILE UPLOAD field is REQUIRED and filled with a filename.
I tested this by removing the FILE UPLOAD field from my old form which always worked fine with PHP mail before but failed when I removed the FILE UPLOAD field.

In all the tests I executed the parameters in Joomla and VI-Forms where the same. I use the latest versions of Joomla and VI-Forms.

I hope you can give me an idea why it fails with PHP mail or why the FROM Name and FROM E-mail fields are not used when I use SMTP mail.

Thank you in advance for your attention to my questions.

Kind regards,
Cees Borst

More
6 years 9 months ago #5191 by Administrator AV
Hi Cees,

thanks a lot for all the work which you did in order to test this and for taking the time to write this post!

I must admit, that I do not have experience with the Joomla! SMTP Mailer. Nevertheless I think, that this (whether or not a mail is send, depending on the existance of a file upload field) is not a common problem with Visforms, because I have not heard of a similar problem before and the mail feature is certainly used by everybody. I think, we have to debug this step by step.

So here my first thoughts and questions.

When you send mails with Visforms, you have to set the Mail From (Address) and the Mail From Name, which you want to be used in the mail, in the form configuration (tab Mail Options). Reading your post, I got the impression, that you always write about Mail From and Mail From Name in Joomla!'s global configuariton, so I was wondering, if maybe you have not set these form options for the result mail and the recipient mail?

You wrote when I use e-mails in the e-mail field with HOTMAIL or GMAIL e-mailadresses. Are you talking about a Visforms form field of type e-mail, and entering HOTMAIL or GMAIL addressess as form inputs in the frontend? Or are you talking about HOTMAIL or GMAIL addressess as Mail From Addressess for the mail configuration?


Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
6 years 9 months ago #5192 by ceesborst
Hallo Aicha,

Thanks for your prompt reply. About your questions I can say the following;
In the options of VisForms I have the following options set to NO for the RESULT mail; Exclude empty fields and and Submitted Mails as Links also set to NO. All other options are set to YES.
For the Result mail the following options are set to NO; Exclude empty fields, Show a Download link and Include "file upload" File. All other options set to YES.

I have set the MAIL From and Mail From name fields in both the Result mail options and the Recipient mail options of the Forms. In addition these fields are set also in the mail options of the Joomla Global configuration as described earlier in my topic.

So with PHP mail option set the result emails are not sent when I use in the e-mail field of the form an HOTMAIL or GMAIL e-mailaddress and there is NO File Upload field on the form. All other options are always the same as described above. When I use my KPN e-mailaddress in the e-mail field of the form I do receive the result e-mails also without changing any option. The GMAIL account uses IMAP protocol. THe HOTMAIL and KPN accounts use POP3 protocol. HOTMAIL and GMAIL accounts use SSL/TLS for the connection security option. For KPN the connection security option is set to NONE. So that could be an important difference

I could work with SMTP mail option but then the e-mailaddress and e-mail from name are set to my GMAIL e-mailaddress and GMAIL name which is not allowed with these forms on www.luchthavenpastoraat.nl website which I developed and maintain for Airport Chaplaincy at Schiphol airport Amsterdam. The URL of the form with an file upload field is luchthavenpastoraat.nl/nl/?option=com_vi...ew=visforms&id=1 . It can't be opened at this moment via a menu option. When I remove the File Upload field I have the "Could not instantiate mail function" problem.

I hope the information above can help you a bit to help me to resolve this problem. Once again thanks for your help.

Kind regards,
Cees Borst

More
6 years 9 months ago #5193 by Administrator AV
In which case do you get the Message "Could not instantiate mail function"?
Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
6 years 9 months ago #5194 by ceesborst
Hallo Aicha,,

I only get this message when I use PHP mail as defined in the Global Configuration in Joomla, when I have no File Upload field in the form and when I use in the e-mail field of the form then my HOTMAIL or GMAIL e-mailadresses. With my KPN e-mailaddress I don't get this error message.

With SMTP I only get the wrong From Name and From E-mailaddress. but not this error message.

I hope this additional information helps to solve the problem.

Kind regards,
Cees Borst

More
6 years 9 months ago #5197 by Administrator AV
Hi Cees,

thanks for your patience!

This morning, I took the time to go through the code that creates mails.

Basically the work flow is as follows.

Visforms gathers the information which are required to send a mail, but the mailing itself is done by the Joomla! phpmailer class, which itself passes the task to the mailer, which you have selected in the global configuration of your Joomla! installation (php Mailer, sendmail or SMTP). This mailer tries to send the mail and returns the information whether or not it was successful. This information goes back the whole way and the Joomla! phpmailer class throws the Error "Could not instantiate mail function", if the return from the mailer was "not successful".

Beside the settings, which you make in Visforms and in the global configuration of your Joomla! installation, there are also settings involved of the php.ini and of the mailers themselve. For example something like "safe_mode" and "mbstring.func_overload" settings (in php.ini). So there are a lot of parties involved in the process which can mess up.

In my experience the "could not instantiate mail function" errors is usually thrown, because, after all the processing of the information through the different instances, the mail from address is missing, in the final stage where the mailer tries to send the mail. But there can of course be other problems with the provided information, which can cause the mailer to break. I think, you should try to get more information about what actually causes the mailer to break. I think you should ask the provider, whether they can supply you with that information.

With regards to the result mail, Visforms uses an email address, which you enter in the frontend in a form field of type email only for one purpose. It is set as "reply to" address in the mail. It is not used as mail from or anything like that. The mail from address and the mail from name come from the email configuration of the form. Why a reply to address with HOTMAIL causes problems and a reply to with KPN not, I do not understand and again, I do not think that it is Visforms that is responisble for this problem in the first place.

The differences between a form with a file upload field an one without such a field are, with regards to the mails, as follows.
Only if the form has fields of type file upload and only if there was actually a file uploaded, Visforms tries to do things with the data from this fields. Only then, it tries to add attachments to the mail (according to the settings in the Visforms result mail configuration) and only then, links to the file are included in the mail body (according to the settings in the field configuration an the form result mail configuration).

I cannot see a fault in how Visforms handles file upload fields with the result mail. Therefore I can only conclude, that the problem is located somewhere else in configuration settings which have nothing to do with Visforms.

With regards to your question, why the smtp mailer does not use the mail from address and mail from name set in the Visforms configuration or the global configuration. Could it be possible, that this is a setting of your smtp mailer account?

I'm sorry, that I do not have an easy solution for your problem. I hope, that giving you the detailed information about the work flow of the mailing here, might help you, to find a solution.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum