After configuration smtp in prameters.yml I trying to send email but I have this type of warning:
ContextErrorException: Warning: mkdir(): No such file or directory in /home/crashend/domains/tombax.com/public_html/gbuy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php line 273
On the localhost everything worked fine but the problem appeared after transfer project to the server. Emails are not deliver.
Code from controller where are send emails:
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom(array('exapmle@abc.net' => 'Tom'))
->setTo(array('exapmle2@abc.net' => 'Jan'))
->setBody('abcd')
;
$this->get('mailer')->send($message);
Code from parameters.yml:
mailer_transport: smtp
mailer_host: smtp.myserver.com
mailer_user: exapmle@abc.net
mailer_password: pass
Please help.
After comment this:
if (is_writable($tmpDir = sys_get_temp_dir())) {
$preferences->setTempDir($tmpDir)->setCacheType('disk');
}
in the /vendor/swiftmailer/swiftmailer/lib/preferences.php everything works fine. I think that the problem was in the permission to the directory. Swiftmailer uses sys_get_temp_dir() function which trying refer to /tmp directory.