XF 2.2 Weird problem with emails (server error log)

Salamanca

Active member
Hi,

We have recently switched to Xenforo from another forum.

We're seeing lots of the error like the one below.
The weirdest part is that it tried to create a dir on C:\ drive on our Windows servers (Xenforo runs on a directory on D:\ drive): mkdir('C:\\Users\\NODE1...')

We don't know what to make of it.

Code:
ErrorException: Email to *******@gmail.com failed: [E_WARNING] mkdir(): No such file or directory src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\KeyCache\DiskKeyCache.php:247
Generated by: Unknown account 11 Μαρτ 2021 στις 00:04
Stack trace
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] mkd...', 'D:\\inetpub\\wwwr...', 247, Array)
#1 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\KeyCache\DiskKeyCache.php(247): mkdir('C:\\Users\\NODE1...')
#2 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\KeyCache\DiskKeyCache.php(74): Swift_KeyCache_DiskKeyCache->prepareCache('dac270811dbed49...')
#3 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\KeyCache\SimpleKeyCacheInputStream.php(55): Swift_KeyCache_DiskKeyCache->setString('dac270811dbed49...', 'body', '
Nikos48 (http...', 2)
#4 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\ByteStream\AbstractFilterableInputStream.php(171): Swift_KeyCache_SimpleKeyCacheInputStream->write('
Nikos48 (http...')
#5 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\ByteStream\AbstractFilterableInputStream.php(91): Swift_ByteStream_AbstractFilterableInputStream->doWrite('
Nikos48 (http...')
#6 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMimeEntity.php(557): Swift_ByteStream_AbstractFilterableInputStream->write('Nikos48 (https:...')
#7 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMimeEntity.php(532): Swift_Mime_SimpleMimeEntity->bodyToByteStream(Object(Swift_Transport_StreamBuffer))
#8 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMimeEntity.php(570): Swift_Mime_SimpleMimeEntity->toByteStream(Object(Swift_Transport_StreamBuffer))
#9 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMimeEntity.php(532): Swift_Mime_SimpleMimeEntity->bodyToByteStream(Object(Swift_Transport_StreamBuffer))
#10 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMessage.php(604): Swift_Mime_SimpleMimeEntity->toByteStream(Object(Swift_Transport_StreamBuffer))
#11 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Message.php(162): Swift_Mime_SimpleMessage->toByteStream(Object(Swift_Transport_StreamBuffer))
#12 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(398): Swift_Message->toByteStream(Object(Swift_Transport_StreamBuffer))
#13 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(500): Swift_Transport_AbstractSmtpTransport->streamMessage(Object(Swift_Message))
#14 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(516): Swift_Transport_AbstractSmtpTransport->doMailTransaction(Object(Swift_Message), 'bounce+194947de...', Array, Array)
#15 src\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(206): Swift_Transport_AbstractSmtpTransport->sendTo(Object(Swift_Message), 'bounce+194947de...', Array, Array)
#16 src\XF\Mail\Mailer.php(304): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#17 src\XF\Mail\Queue.php(138): XF\Mail\Mailer->send(Object(Swift_Message), Object(Swift_SmtpTransport), Array)
#18 src\XF\Job\MailQueue.php(12): XF\Mail\Queue->run(8)
#19 src\XF\Job\Manager.php(258): XF\Job\MailQueue->run(8)
#20 src\XF\Job\Manager.php(200): XF\Job\Manager->runJobInternal(Array, 8)
#21 src\XF\Job\Manager.php(84): XF\Job\Manager->runJobEntry(Array, 8)
#22 job.php(43): XF\Job\Manager->runQueue(false, 8)
#23 {main}
Request state
array(4) {
  ["url"] => string(14) "/forum/job.php"
  ["referrer"] => string(65) "https://www.********.com/forum/threads/survivor-4.321879/page-439"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
This value should be coming from the PHP function sys_get_temp_dir, which gets the temporary directory that PHP will try to use. Ultimately, by default, PHP will call some Windows APIs to get what is defined as the temporary directory there.

It looks like you can specify it directly by setting the sys_temp_dir value in your php.ini file to a specific path.
 
Hi,

We have updated sys_get_temp_dir with value "sys_temp_dir = "C:\Windows\Temp"" and we have verified that indeed it works:

PHP:
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');

echo $temp_file;
?>

This returns:

Code:
C:\Windows\Temp\TuxF705.tmp

However, it did not solve the problem in Xenforo. We continue to get the same exact error.
 
As far as I can tell, this really should be using that so I'm not clear on why it's not working unless there is some code being hit that isn't expected.

You could try adding this to your src/config.php file as that should explicitly override that path used:

Code:
Swift_Preferences::getInstance()->setTempDir('C:\Windows\Temp');
 
Top Bottom