We have a cron set up in Symfony 1.4 to send out several emails each morning. For some reason, today, it attempted to send via localhost rather than via the SMTP server we have configured in factories.yml. We don't have localhost on the production server so naturally this failed.
A couple new things that happened:
we actually replaced the cron yesterday with new code ... but the new code is using the same project / mailer configuration as the old one, so I don't see how this could cause a problem.
there are some new members on the team, from another company, and they have only recently gotten server access / started committing code. I can't see any changes made to factories.yml ...
Any idea what might be causing this? Any hints on where to search?
Try to clear your cache
php symfony cc
Related
Moving an old Joomla 2.5.x install from an old win 2008 server to a win 2016 server. We will be upgrading to the latest version of joomla/php in the future, but for now I'm trying to get the current (old) version working. PHP is 5.4.10
I have the joomla site itself working. Although the contact form does not work. It throws the error 'Could not instantiate mail function' when you try to send.
Joomla is running under the same php install - i copied it from the old server. The joomla config is the same as well, except for updating hostname/paths etc where relevant. I've searched through all the files on the new server looking to see if anything was pointing to the mail server on the old machine - did not find anything. And i have confirmed the mail server on the new machine is working - sent an email to myself as well as telneted to port 25 to confirm it's accepting local connections. But I'm guessing from the error, it's failing before it even tried to connect to the mail server. And the file paths should be the same between the two servers as well.
At this point my guess would be there's some difference between IIS 7.x and IIS 10.x that's causing this, but that's just a guess. Hopefully someone else might have a more specific guess? ;)
thanks in advance for any help.
Ok, looks like the issue isn't with the mailer, it's with dns. It's not resolving anything.
$dnsrecs = dns_get_record('google.com'); returns dns query failed. However, dns on the server itself appears to be working. nslookup from the command prompt works. I even tried switching name servers to googles server - which also works from the command prompt but not from within php. Since this is an entirely different issue from the original topic, I'll mark this as answered and open a new question.
For years our website has used the SwiftMailer plugin to send emails via Gmail. However, seemingly randomly yesterday morning it no longer works for us; we get a message
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [ #0]'
Any ideas what might have caused this? Did Gmail change something with the settings we need to use? Here's what we have currently:
require_once 'path/to/swift-mailer/lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com')
->setPort(465)
->setEncryption('ssl')
->setUsername('ouremail#gmail.com')
->setPassword('ourpassword')
;
$mailer = Swift_Mailer::newInstance($transport);
The problems started around 11AM yesterday morning, and absolutely nothing was changed on our end around that time. Last week I upgraded our PHP version to 5.6.32, but things were working fine since that upgrade until yesterday morning. I even tried reverting back to the old version (only back to 5.6.30), but the error still persisted. I have researched everything on here and elsewhere on the web I could find on this issue and tried everything I could, including trying TLS, changing the port number, using an IP instead of smtp.gmail.com, but nothing has worked. Any ideas?
EDIT: Just discovered the email still works from my local XAMPP setup. This setup is running PHP 5.5.9. So it must be something with our server or domain name provider.
This should be a comment but 1) its a bit long, 2) the comments section is already full of irrelevance.
So you have code which was known to be working but the intended behaviour changed without a change in the code. And you thought to ask why on a site about code problems?
Something has changed outside your code. That's the first place you should be looking.
If gmail had suddenly stopped working or changed its behaviour, I'm fairly sure there would be a lot of people talking about it. Hence the most likely candidate is the infrastucture (including the CAs) supporting your PHP server. But:
1) you've told us nothing about that
2) its off-topic on SO.
I got the same issue that the swift mail just suddenly stop working.
The error is
'Connection could not be established with host smtp.gmail.com [ #0]'
.
I am using laravel with swift mail to send email through gmail box.
The final solution is to download the cert from https://curl.haxx.se/ca/cacert.pem
then add "openssl.cafile=path\cacert-2018-01-17.pem" to php.ini.
It's because something related to windows ca library is not updated any more.
I have a problem with configuration of SMTP using SwiftMailer, which I managed to solve it temporarily. I changed the password from my mailer and I changed the settings at the SMTP's config file too with the updated one for registration usage at my website.
While the registration was working perfectly at local using WAMP, when a new user was trying to register at the website the confirmation e-mail was sent to the user's mail correctly and everything was fine, but this didn't work at the online version of the site, while I changed the same parameters in server's file too.
I didn't make any changes at the code so the coding is working well. When I looked at the log files of the server, the error seemed to be "Failed to authenticate on SMTP using 2 possible authenticators", so I changed the password back to the previous one and registration is working perfectly at the online version too.
I think that there is a possibility that the SMTP is taking the previous settings from some cache files? Is it possible to happen? And how can I deal with this?
You probably have to clear symfony cache, so new setting will take effect (on production env). This is for symfony 3.
php bin/console cache:clear --env=prod
You could manually send email via swift mailer (how to spool emails) and you will have to provide all the parameters when asked:
php bin/console swiftmailer:spool:send --env=prod
I'm stuck on this one. I'm working on a project to automatically deploy and configure Mautic instances on AWS's Elastic Beanstalk using Docker containers. Everything appears to be in order, but when I click the "Test Connection" in the email settings of Mautic's configuration, I always get "Unable to connect with TLS encryption."
If I don't use any encryption, I'm able to connect just fine and send emails. So it's not a blocked port issue or bad credentials.
I've made sure OpenSSL is installed and running in PHP.
Mautic is using swiftmailer to send emails, so I went into their code, and copied the exact snippet of code they use to test. I inserted this into a test script like so, and ran it.
<?php
require_once __DIR__ . '/vendor/autoload.php';
try {
$mailer = new \Swift_SmtpTransport('...', 587, 'tls');
$mailer->setUsername('...');
$mailer->setPassword('...');
$mailer->start();
die('hello');
}
catch(Exception $e){
echo $e->getMessage();
}
That works fine. I went so far as adding the rest of the code needed to send the email, and it came to my mailbox just fine. This script was executed from inside the docker container that's on the AWS Elastic Beanstalk server.
So what am I missing? Why is this failing me when testing through mautic?
The test script also uses the same vendor folder that the Mautic instance is using so I know it's using the exact same version of SwiftMailer.
Thanks
==
UPDATE 1
Downgrading to PHP 5.5 from PHP 5.6 seems to have resolved this issue, but I don't like the idea of downgrading PHP just to solve a problem. I got the idea from this issue
So if anyone has a better solution, I'm still open. I do notice in the issue, someone has pointed out a solution for 5.6, but it involves editing vendor files, which doesn't work for me since I'm trying to automate all of this.
I spent half day to find out how to connect with Mautic 2.16.2 and PHP 7.1.
The problem is TLS version constant defined in SwiftMailer (STREAM_CRYPTO_METHOD_TLS_CLIENT). For backwards compability it points to 1.0 v. of TLS. You can change
STREAM_CRYPTO_METHOD_TLS_CLIENT to STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT (or other version) in /mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php.
For further information check this SwiftMailer issue
I had a simular problem. Recently got solved with two things: First, updated to the 2.0.0 release, then I figured out (although not sure if true) that the cron jobs had to be in a very specific order at my host (godaddy server) with none of the doohicky code at the end, like this:
mautic:campaigns:trigger
mautic:campaigns:rebuild
mautic:iplookup:download
mautic:emails:send
mautic:email:fetch
mautic:segments:update
After Mandrill announced it wasn't going to be free anymore, I started looking for an alternative. I found Sendgrid which will suit my purposes.
I updated the Environment file with MAIL_USERNAME, MAIL_PASSWORD, and MAIL_HOST information for Sendgrid on Forge. On my local machine it works and sends through Sendgrid. On my production, it keeps sending through Mandrill even though the environment file has been updated and Mandrill information deleted. How is that? Does Forge use a cache file for the environment that needs to be deleted?
The problem was fixed by restarting the queue worker after the environment file was updated. Confirmed by #retrograde.