SMTP access old settings from cache? - php

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

Related

Failed to authenticate password smtp PHP

After less secure password option is not available anymore I tried to implement app password in gmail however it is showing me an error:
this is my email.php configuration I am using codeigniter 3.
what I did was use my email and just paste the password in the smtp password but is not working. How can I make it work? In my local development it works fine but after deploying it to heroku it does not work anymore.
Make sure the 3 steps like in this link https://stackoverflow.com/a/73357021/13633617 have been done because it seems that in the details of the question, only 1 step is done (create an app password). It worked smoothly for me.

Using SwiftMailer to send via Gmail suddenly stopped working?

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.

Laravel Mail SSL Error

while working on my current project, I already started to experience problems after trying to implement the Password Reset function based on the scaffolding that Laravel provides.
Currently, I am only using the default routes and controllers for the password reset procedure.
When it came to testing that functionality, I got the following error:
stream_socket_enable_crypto(): SSL operation failed with code 1
I checked my mail server and I saw that I hadn't yet implemented the new Certificate from Let's Encrypt but was still using a self-signed one. After fixing that issue and also taking care of the intermediate certificate for the Lets Encrypt CA, I checked my server with this tool: https://ssl-tools.net/mailservers/mail.dream-code.eu
This clearly states, that my server is not having any SSL issues anymore, but still, I receive the same message from Laravel when I try to use the Mail function. Is there any known issue about this or do I have to take further steps?
I found something about Laravel 4.2 where you had to change the mail provider from smtpto mail which had fixed the issue for some people but this was also not successful. When I used that mail provider, there was no error but I also did not receive an E-Mail. Neither in the default folder, nor in the spam folder.
When I "manually" send mails via Thunderbird from the same address that is set for Laravel, there is no problem, the E-Mail arrives just a few seconds after sending.
Just in case it's somehow relevant, I try to send to a gmail address. The mail server is a Dovecot/Postfix Combo with the already mentioned Let's Encrypt certificate. PTR Record is configured correctly.

What is required on web server to send email using PHP/HTML form using Nginx?

I currently have a static website that I am trying to send an email form from. I am using a simple HTML form with fields such as name, email, message, etc. The PHP form is also very straight forward. I don't think there are any problems with the code. In fact, the code is basically exactly like any online tutorial you'd find (http://www.freecontactform.com/email_form.php). I think the problem has to do with the config on the server. I have a Digital Ocean server with Nginx. At first, when I tried to submit the email form I was getting a 405 error. Now that I handle 405 errors in the config file, I am getting the PHP form as a download when I hit the submit button. What do I need to install on the server or include in the config file to make this PHP email form work?
Edit/Update: I have installed Postfix on my web server and am able to successfully send emails from command line using Postfix to different emails outside the server (for instance, I can send from my root user to my personal email addresses on Gmail, etc.). I now have another problem...
This still doesn't help me on the front-end. When I try to click the submit button on the web page form it is still just downloading the PHP file. I think I am missing something in the php.ini folder and maybe some other things as well. Even though I have mail set up on the server, the PHP action button has no idea that it's set up or something along those lines.
You need to install a Mail Transport Agent (MTA) like postfix or exim4. I think you can configure nginx to rely emails to another smtp server.
Another way, would be installing swiftmailer and connect it with an email sending service as sendgrid, mandrill, sparkpost, etc.
Edit:
I personally recomend a sending service as they have white-listed IP for their sending services plus you save memory in your VPS server (as an MTA daemon is not required to run there).
I'm using sparkpost for a few projects and is working perfectly. They have a pretty high limit for a free account.
With any service you choose, ensure to enable DKIM and SPF to avoid been detected as spam.

Why did SwiftMailer send via localhost

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

Categories