Apen / additional_scheduler

Useful tasks in the scheduler module : full backup, send query result in mail, exec SH script with reports...
Other
8 stars 9 forks source link

Exception when executing a shell script #17

Closed schrej-zz closed 2 years ago

schrej-zz commented 2 years ago

Hi, after updateting to 10.4.x and additional_scheduler 1.5.6, I get the following exeption when executing a shell script:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Argument 1 passed to Symfony\Component\Mime\Address::__construct() must be of the type string, null given, called in /homepages/11/d582349469/htdocs/xxx/htdocs/typo3conf/ext/additional_scheduler/Classes/Utils.php on line 61 | TypeError thrown in file /homepages/11/d5823494yy/htdocs/typo3_src/typo3_src-10.4.21/vendor/symfony/mime/Address.php in line 42. Requested URL: https://www.xxx.de/typo3/index.php?route=%%2Fmodule%%2Fsystem%%2FtxschedulerM1&token=--AnonymizedToken--&tx_scheduler[execute][]=15

This worked with 9.5.x

Apen commented 2 years ago

is your "$GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']" filled? The script get the default address.

schrej-zz commented 2 years ago

Yes, it's filled with the default address. As I said, it worked in 9.5.x

I also see in the debug that the following is transfered to the routine:

Sng\Additionalscheduler\Utils::sendEmail('webmaster@xxx.de', 'Removed old Backups', '/kunden/homepages/11/d5823494yy/htdocs/xxx/htdocs/tools/rm_backup.sh', 'plain', 'utf-8')

schrej-zz commented 2 years ago

Maybe the from[0] doesn't get the right value in utils.php: if (version_compare(TYPO3_version, '10.4.0', '>=')) { $mail ->from(new Address($from[0])) ->to(new Address($to)) ->subject($subject); as here you changed anything for version 10.4.x and upwards

schrej-zz commented 2 years ago

I'm poking around in the dark a little bit. I think based on the documentation, new Address($from needs 2 Arguments. The second one is the "$GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] See: ->from(new Address('jeremy@acme.com', 'Jeremy'))

schrej-zz commented 2 years ago

Well, I think, in 10.x, there is no need for defining "$from" anymore,, and I'm not sure, if the "$from = MailUtility::getSystemFrom();" fuction delivers any reasonable value in 10.4.

So I tried to just comment the "->from(new Address($from[0]))" out, as the value is automatically set from my understanding.

And now it works again. Shell script runs and sends expected mail with right "From" and "From Name".

Joerg

NasimoOo commented 2 years ago

Had the same Error on TYPO3 10. Commenting out the line ->from(new Address($from[0])) in typo3conf/ext/additional_scheduler/Classes/Utils.php worked.

schrej-zz commented 2 years ago

There was no more feedback from Apen, but I think, the issue is solved in newer versions. Therefore, I close the issue.

Apen commented 2 years ago

Nice, thanks for the feedback and sorry for late response...