XF 2.0 Error "preg_split() expects parameter 2 to be string, array given"

affLIFT

Active member
I've seen this pop up quite a few times in the past week. It doesn't appear to be caused by an add-on. Any ideas?

Screen Shot 2018-10-15 at 3.21.38 PM.webp
 
Are you using any addons that touch the email system or send emails?

Can you copy & paste the full error including the request state.
I do have add-ons that use the email system.

ErrorException: Email to useremail@gmail.com failed: [E_WARNING] preg_split() expects parameter 2 to be string, array given
src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php:337

Stack trace
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] pre...', '/var/www/html/f...', 337, Array)
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php(337): preg_split('~(?=[\\t ])~', Array)
#2 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php(284): Swift_Mime_Headers_AbstractHeader->getEncodableWordTokens(Array)
#3 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php(106): Swift_Mime_Headers_AbstractHeader->encodeWords(Object(Swift_Mime_Headers_UnstructuredHeader), Array)
#4 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php(324): Swift_Mime_Headers_UnstructuredHeader->getFieldBody()
#5 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(519): Swift_Mime_SimpleHeaderSet->toString()
#6 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php(617): Swift_Mime_SimpleMimeEntity->toByteStream(Object(Swift_Transport_StreamBuffer))
#7 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php(170): Swift_Mime_SimpleMessage->toByteStream(Object(Swift_Transport_StreamBuffer))
#8 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(327): Swift_Message->toByteStream(Object(Swift_Transport_StreamBuffer))
#9 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(428): Swift_Transport_AbstractSmtpTransport->_streamMessage(Object(Swift_Message))
#10 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(444): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'hello@afflift.c...', Array, Array)
#11 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(176): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), 'hello@afflift.c...', Array, Array)
#12 src/XF/Mail/Mailer.php(289): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#13 src/XF/Mail/Queue.php(65): XF\Mail\Mailer->send(Object(Swift_Message))
#14 src/XF/Job/MailQueue.php(11): XF\Mail\Queue->run(8)
#15 src/XF/Job/Manager.php(241): XF\Job\MailQueue->run(8)
#16 src/XF/Job/Manager.php(187): XF\Job\Manager->runJobInternal(Array, 8)
#17 src/XF/Job/Manager.php(76): XF\Job\Manager->runJobEntry(Array, 8)
#18 job.php(15): XF\Job\Manager->runQueue(false, 8)
#19 {main}

array(4) {
["url"] => string(10) "/f/job.php"
["referrer"] => string(22) "https://afflift.com/f/"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
This isn't something we've had any other reports of, so it very well could be related to an add-on. The trace doesn't show it, but this is handling the mail queue; the mail building process would be the potential place for incorrect data to be set. Unfortunately, that's fairly difficult to debug, short of disabling add-ons to see if it keeps happening.

Beyond that, the only thing I could recommend is checking your email-related settings in the XF options. Make sure you've set values that are correct/valid for each of them. (Random thing that comes to mind is whether there are multiple emails set somewhere where one is expected, though that would likely block every mail.)
 
Back
Top Bottom