I'm trying to setup Laravel auth including the 'Password Reset' function. But I am stumbeling upon a error when I try to send the email. The error I get is:
Expected response code 250 but got code "550", with message "550 Bad HELO - Host impersonating domain name
Im using Laravel 5.6 with Cloudflare. My hosting said that that might be the issue but I've already tried to disable all Cloudflare DNS functions inside the Cloudflare Dashboard, but that didnt work. I am sure I am using the correct mails settings since they work fine on my phone and any other devices.
Also, I've tried switching ports and it doesnt matter if I fill in a valid port or not, it will keep giving me this error.
Laravel 5.6 uses $_SERVER["SERVER_NAME"] as your local domain.
You should change localdomain to your MAIL_HOST
This worked for me:
config/mail.php
'localdomain' => env('MAIL_HOST')
And you should make a little change in vendor:
vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php
//->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1')
->asValue(config('mail.localdomain'))
Replace commented code,
I Know this is the worst solution but it seems that there is no other solution.
#bardia-mazaheri is right but better solution is to do it like this:
class AppServiceProvider extends ServiceProvider
{
public function register()
{
// There is a bug in which the Swift library loads 'transport.localdomain' value from $_SERVER['SERVER_NAME']
// which results to wrong host name for email server and causes an error:
// Expected response code 250 but got code "550", with message "550 Bad HELO - Host impersonating domain name
// described here https://stackoverflow.com/questions/55279922/550-bad-helo-host-impersonating-domain-name-laravel
\Swift_DependencyContainer::getInstance()
->register('transport.localdomain')
->asValue('mail.domain.com');
}
}
I ran against the same problem and i tried the above answer but it did not help me, but the following worked for me for strange reasons...
In your /config/mail.php add the following line:
'localdomain' => 'localhost'
don't ask me why xD
Related
I tried all the solutions given to questions similar to mine (allowed less secured apps, display captcha, using 465 port for ssl, etc).
Can anyone tell if I have to change any settings on cpanel to send mails using gmail?
I remove below line from localhost code and it worked.
define("MAILER", "smtp");
Above line is not required and causing the error
I am using the FOSUser bundle within my Symfony2 application. I am trying to get the email functionality working but can't get any emails to send successfully.
My development environment is a Ubuntu virtual machine. I tried to use my Gmail account details as described here. I also checked the error logs but nothing regarding the email sending is logged.
I attempted to send a test email using a test controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class TestEmailController extends Controller
{
public function sendEmailAction()
{
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send#example.com')
->setTo('me#myemailaddress.com') // use a valid email in actual code...
->setBody('yo, wassup!');
$this->get('mailer')->send($message);
return $this->render('SysDevPunctualityBundle:TestEmail:sendEmail.html.twig', array(
// ...
));
}
}
However this triggers an error with Symfony's web profiler toolbar and I get the following message; "Token "3c494e" was not found in the database."
After some digging around I found this question I followed the suggestion of removing the spool option and also added a 'from_email' option. This made a difference, I am now getting a timeout error:
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
My guess is that the firewall is blocking the request, I don't know how to find out for sure.
Appreciate if anyone can point me in the right direction.
I discovered that the source of the problem was that my work firewall was blocking access to the Gmail SMTP server. I switched to another SMTP server (set up by our IT department) and email sending now works fine.
Check these two links from the cookbook, to find out how to handle emails while developing: http://symfony.com/doc/current/cookbook/email/dev_environment.html & http://symfony.com/doc/current/cookbook/email/spool.html
Whenever a new user tries to create a new account, they get this message
Tried to send you an email but failed!
I tried setting up an email and using the smtp settings in Site
Administration -> Message output -> Email and that did not work.
I called my Host company (inmotion hosting) and they verified that my
settings were correct.
I tried just leaving the settings blank in email so that the phpmailer would send the emails, but that is not working and I still get the same message.
I have searched all overand I cannot find any helpful information on why this is happening,
but I find A LOT of people who are having this issue.
This has turned into a MAJOR show stopper and I am wondering what avenues I have to troubleshoot this. Does anyone have any information on how this is fixed?
Thanks in advance.
It might be missing a "from" email - have you got a support email set up?
/admin/settings.php?section=supportcontact
Or go to Site Administration > Server -> Support contact
I've had a similar issue. It works fine for the first three users created (in quick succession) but then fails for a few minutes. Enabling debugging (Site Admin -> Development -> Debugging page) showed that this was due to timeouts:
Debug info:
Error code: auth_emailnoemail
Stack trace:
line 463 of /lib/setuplib.php: moodle_exception thrown
line 106 of /auth/email/auth.php: call to print_error()
line 70 of /login/signup.php: call to auth_plugin_email->user_signup()
Output buffer: profile_field_PC<pre> SMTP -> ERROR: Failed to connect to server: Connection timed out (110)SMTP connect() failed. </pre>
This appears to be an anti-spam "feature" of the Amazon SES service we were using, which we will need to get around.
I know this is an old post but I will add my solution and give many thanks to Russell for that part of it.
This site had been moved over to Bluehost and come to discover that client did not set up an email account for Admin User - so in addition to checking that there is an email in the Admin settings, also verify that that email address exists and is reachable!
SwiftMailer is the default way of sending email from a Symfony 2 project, and I'd like to use it in an application. I've pointed it towards the SMTP server provided by my internet provider (Virgin Media, in the UK), but my emails are not successfully sent. The exception thrown says
Expected response code 250 but got code "501", with message "501 HELO requires valid address
in response to the SMTP command
HELO [::1]
[::1] corresponds to localhost in IPv6, and it's not that surprising that the SMTP server would reject that if it's expecting a proper domain name. Tracing execution through the Swiftmailer source, I find that this value comes from _domain on AbstractSmtpTransport; altering the value during the debug session allows the email to be sent. Although it can be set using the public setLocalDomain() method, it isn't anywhere in the Symfony 2 framework, so it seems that there is no way (obvious to me, at least) of easily configuring this value simply by, for example, changing a Symfony config file.
So my question is this: is there some other way of changing this value, ideally using config, without my diving into the Symfony code and changing bits that aren't meant to be changed? And if so, what?
From inside a Symfony controller, you can configure the HELO/EHLO name like that:
$this->get('swiftmailer.transport')->setLocalDomain('your.domain');
Unfortunately no.
The code for get the local domain in SwiftMailer is:
/** Try to determine the hostname of the server this is run on */
private function _lookupHostname()
{
if (!empty($_SERVER['SERVER_NAME'])
&& $this->_isFqdn($_SERVER['SERVER_NAME']))
{
$this->_domain = $_SERVER['SERVER_NAME'];
} elseif (!empty($_SERVER['SERVER_ADDR'])) {
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
}
}
So, is guessed and it's server configuration.
I opened an issue for SwiftMailer to do this:
https://github.com/swiftmailer/swiftmailer/issues/453
UPDATE: The issue has been resolved on Feb 27th 2018.
When I send an email with the PHP Swift mailer to this server: smtp.exchange.example.com like this:
// Load transport
$this->transport =
Swift_SmtpTransport::newInstance(
self::$config->hostname,
self::$config->port
)
->setUsername(self::$config->username)
->setPassword(self::$config->password)
;
// Load mailer
$this->mailer = Swift_Mailer::newInstance($this->transport);
// Initialize message
$this->message = Swift_Message::newInstance();
// From
$this->message->setFrom(self::$config->from);
// Set message etc. ...
// Send
$this->mailer->send($this->message);
I get a strange error back:
Failed to authenticate on SMTP server with username "user#example.com" using 2 possible authenticators
I know for sure that the login-info is correct.
This might be old but somebody might get help through this. I too faced the same problem and received a mail on my gmail account stating that someone is trying to hack your account through an email client or a different site.
THen I searched and found that doing below would resolve this issue.
Go to https://accounts.google.com/UnlockCaptcha‎
and unlock your account for access through other media/sites.
UPDATE : 2015
Also, you can try this, Go to https://myaccount.google.com/security#connectedapps
At the bottom, towards right there is an option "Allow less secure apps". If it is "OFF", turn it on by sliding the button.
UPDATE : 2021
The google URL has now changed to : https://myaccount.google.com/lesssecureapps. You will be asked to relogin
I had the same issue, so I've disabled one setting on my WHM root login, which is as follows :
WHM > Home > Server Configuration > Tweak Settings > Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) [?]
I really have the same problem, finally, i solved it.
its likey not the Swift Mail's problem. It's Yaml parser's problem.
if your password only the digits, the password senmd to swift finally not the same one.
swiftmailer:
transport: smtp
encryption: ssl
auth_mode: login
host: smtp.gmail.com
username: your_username
password: 61548921
you need fix it with double quotes
password: "61548921"
I just received the same error.
The strange thing is that commented the credential lines
// ->setUsername(self::$config->username)
// ->setPassword(self::$config->password)
And the problem disappeared.
I'm puzzled because the mail server definitely needs those credentials.
I tried almost all the possible suggestions mention here but for me problem got solved after changing "Access for less secure apps" to ENABLE in my Google account security settings tab. Hope this might useful for others !
The server might require some kind of encryption and secure authentication.
see http://swiftmailer.org/docs/sending.html#encrypted-smtp
try putting username in double quote "username", somehow that fixed for me.
I faced the same problem and solved it. Try to log in manually to your gmail account first.
This issue is due to google has detected your gmail account has been abusing. E.g send a lot of emails over a short period of time.
You perhaps use the wrong username.
I had a similar error. Ensure you're not using uppercase while logging into server.
Example: JacekPL#lala.pl
If you use ->setUsername('JacekPL'), this can cause an error. Use ->setUsername('jacekpl') instead. This solved my problem.
First check if there is any connectivity problem and you can reach the SMTP server:
In terminal type:
telnet servername portnumber
If you receive the 220 response you can reach the SMTP server and there is no connectivity problem but if the connection to the server failed see what's wrong in your network.
If the server needs auth try to authenticate on the server by username and password and see if something goes wrong.
At last see if the server requires encryption and if yes openssl and other stuff are configured correctly.
I got the same same error.
I was using gmail account and Google's SMTP server to send emails. The problem was due to SMTP server refusing to authorize as it considered my web host (through whom I sent email) as an intruder.
I followed Google's process to identify my web host as an valid entity to send email through my account and problem was solved.
If you are trying to send mail from your local enviroment eg. XAMPP or WAMP, this error will occur everytime, go ahead and try the same code on your web hosting or whatever you are using for production.
Also, 2 step authentication from google may be the issue.
Strange enough sending emails works again. We did not change anything and the host say they did not either. We think a server restarts or so. It is strange :S