I am following a tutorial to build an API using passport authentication on enter link description here
I have followed the part 1 and walking through the part 2 with account confirmation and notifications but eventually got a problem when I am testing on POSTMAN. The issue is, it does add to the database only that there is no mail sent with the error. I don’t know of there is any configuration I need to do in .env or mail.php. As I tried to configure the email address, STMP and password. The same error is displayed again and most issues I have seen on here are quite different as most are pertaining to mail.php and .env which I have no idea as there is no such on the tutorial link and I even tried to alter the mail.php and .env, I ran php artisan cache:clear but the same error is displayed.
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class SignupActivate extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return IlluminateNotificationsMessagesMailMessage
*/
public function toMail($notifiable)
{
$url = url('/api/auth/signup/activate/'.$notifiable->activation_token);
return (new MailMessage)
->subject('Confirm your account')
->line('Thanks for signup! Please before you begin, you must confirm your account.')
->action('Confirm Account', url($url))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
I did also, two ways authentication
Mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'username@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Payne Curtis'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=XXXXXXXXXXXXXXX
MAIL_ENCRYPTION=null
При отправке письма: Expected response code 220 but got an empty response
'mail' => [
'class' => 'yiiswiftmailerMailer',
'viewPath' => '@backend/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'my_email',
'password' => 'may_password',
'port' => '465',
'encryption' => 'ssl',
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Labels
1.7.7.0
Affects versions
Advanced parameters
Component: Which BO section is concerned
BO
Category: Back Office
Bug
Type: Bug
Can’t reproduce
Resolution: issue closed because cannot be reproduced
Label: Which BO under menu is concerned
Topwatchers
Backlog prioritization: issue reported & followed by +6 people
Comments
After i upgraded to 1.7.7 i started havng customers call me and say that they got no email or response that their account or message was created/sent..
i went into email settings and tried to send an email and i got the following message..
###############################
Error: Please check your configuration
Expected response code 220 but got an empty response
#########################################
The email is set to «Use /usr/sbin/sendmail»
Moreover i tried to setup my own SMTP par according to my server to no success..
Additional informations
Prestashop version: 1.7.7.0
PHP version: 7.3.23
Hi, in PS 1.7.7.0 we had to disable the use of mail() for security reasons (details #20124).
But /usr/sbin/sendmail or SMTP should work fine 🤔 .
matks
changed the title
Email error / response code 220 after upgrade to 1.7.7
Email sending error (response code 220) after upgrade to 1.7.7
Dec 5, 2020
Still… i have 4 Prestashop installations that now give this error..
Hello @Stampa-Stampa
we need more information. When you create an issue, there is a template with some sections you’re supposed to fill with the correct information, not delete everything…
Could you please do that ?
Thank you in advance.
Hi there…
The section you mention has nothing to fill or delete when you use the default option (/usr/sbin/sendmail)..
Moreover it was working fine before the update.
Cant understand why Prestashop decided to move with such a change without being sure there is functionality or at least a workaround.
Nevertheless on other server the email test goes on for ever and it ends up with timeout after 4-5 min..
Setting up smtp option ends up with :
################################
Error: Please check your configuration
Failed to authenticate on SMTP server with username «Info@stampa-stampa.com» using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code «535», with message «535 Incorrect authentication data «. Authenticator PLAIN returned Expected response code 235 but got code «535», with message «535 Incorrect authentication data «.
###########################
The same smtp setting work just fine on other email clients.
Cant understand why Prestashop decided to move with such a change without being sure there is functionality or at least a workaround.
mail() has been disabled because it’s not secure swiftmailer/swiftmailer#866 (comment)
Replacement is /usr/sbin/sendmail and SMTP and they work well. In your usecase something seems wrong but it works for standard prestashop environment.
@matks I told you this is going to be a problem… We asked all major hosting providers in Czech republic and all of them refused to enable sendmail. 😞
@matks I told you this is going to be a problem… We asked all major hosting providers in Czech republic and all of them refused to enable sendmail. 😞
I’m sorry but if I don’t remember that 😅 but github notifications are like a never-ending rain so I might have missed something.
But once mail() has been declared unsafe we cannot keep it. Security comes first. There are hundred email providers available 😊 I dont think we have limited options.
hello @Stampa-Stampa
Could you please provide your previous PS version and your PHP version.
Thanks!
@matks Wasn’t you, sorry 😄 #19957 (comment)
It’s quite a situaliton we can never win. mail() is considered unsafe, but proc_open() is disabled everywhere, because it poses even bigger threats.
Reading the answer from @atomiix it seems the other alternative is to use your own SMTP parameters. Is it a viable option for you ?
@Stampa-Stampa I was not talking about the configuration in PrestaShop, I was talking about the issue template, when you create an issue on Github. We have a template with some sections to fill (environment, steps to reproduce, other important details) and you deleted everything.
I finally managed to setup smtp but still more problems apear …
I have added a new issue…
My Prestashop version is 1.7.7.0 and my php version is 7.3.23
Hello @Stampa-Stampa
Could you please provide your previous PS version and your PHP version.
I said your previous version 😅 So what was your shop version before upgrade.
Thanks!
It appears sendmail via swiftmail needs «proc_open» — which most php installations, has disabled via disable_functions, for security reasons!
Same problem after upgrading to 1.7.6.9 ->1.7.7
Same problem since update to 1.7.7, «Error sending e-mail (response code 220)».
cannot configure the mails in SMTP because hosting on ionos on a shared server. How to do?
Same problem here… pretty messed up that this breaks without notice.
Where is the «send from» email configured now with sendmail?
i also have this problem
Error: Please check your configuration Expected response code 220 but got an empty response
close
An error occurred while sending the e-mail to the customer.
I am not sure it will help but i couldn’t even setup my own smtp. The browser i was using was firefox and what i realised was that the browser somehow was changing the pass according to an autoregistry without me noticing it, and i got a break when i tried the same with a chrome.
Same here, tried different browsers amd accounts without any luck.
This should have been handled way better during the upgrade process. There should have been an automatic email test and if it doesn’t work it should clearly inform the user after the upgrade process that the email sending is not working anymore and it should be reconfigured. There was no notice at all. Without looking deep into the changelog one wouldn’t have even noticed the change in the email settings wording until seeing the emails aren’t arriving anymore (e.g, «new order» notifications, which is what happened to my client).
Hello everyone,
this change was made for security purposes. I understand some of you may feel frustrated, but remember that security is one of our top priorities and as such we removed this feature to keep PrestaShop as secure as possible.
I want to also remind you that we published 3 preversions (beta 1, beta 2, RC 1) before releasing the final product. We ask for people to test these preversions with a copy of their production shops to catch any problem before the final build is released. We need people to test them. Sadly we didn’t receive a lot of feedbacks, feedbacks that could have helped us catching this in advance.
Thank you for your understanding.
I totally agree that security comes first, and I therefore fully agree with removing the usage of php mail. What I don’t agree with is not implementing something like an automated test during the upgrade to see if the new default option still works, or at least telling the user «hey, your email configuration changed, please make sure it still works». I think it’s quite a breaking change. The standard message after upgrade doesn’t help end users that upgrade with the auto upgrade module. Breaking changes should be tested and informed better, IMHO. In my client’s case, sendmail doesn’t work even with it enabled on the hosting and the correct path. Had to configure it as SMTP.
@Ouro17 You are right! indeed some «cleaning» happens when you submit the password.
Could you please open another github issue so we can treat this? Or I can open it if you prefer
@Ouro17 I reported it #22540 so we can start dealing with it ASAP 😊
Hello,
I have a similar problem. I newly founded an eshop with prestashop version 1.7.7.0 and I can’t send any emails. According to the information here, it is possible to send using smtp, which unfortunately has my hosting disabled (cesky-hosting.cz).
My question is, what should I do to send emails using sendmail?
Thank you very much in advance for your help.
Hello,
I have a similar problem. I newly founded an eshop with prestashop version 1.7.7.0 and I can’t send any emails. According to the information here, it is possible to send using smtp, which unfortunately has my hosting disabled (cesky-hosting.cz).
My question is, what should I do to send emails using sendmail?
Thank you very much in advance for your help.
Hello,
I’m afraid that cesky-hosting.cz will also have disabled proc_open library (security reasons) which is required for sendmail. But you should test it to verify it.
Hi @web-plus @Lukascisar if I understand correctly how proc_open works, it prevents the use of SMTP if you use your hosting provider as a SMTP provider.
If you use another SMTP provider like Sendgrid or Mailgun it should work 🤔 (not 100% sure, I’m not experienced in this area).
Hi there…
Maybe upgrading your host plan or changing your host provider is the best
thing to do.
Setting up your own email service (smtp) is the proper way…
Since i setup my own i had no issue and all emails are received and sent
problem free (i had some speed issues prior to that maybe was relevant
maybe not)
…
Hi @web-plus @Lukascisar if I understand correctly how
proc_openworks, it prevents the use of SMTP if you use your hosting provider as a SMTP provider.If you use another SMTP provider like Sendgrid or Mailgun it should work 🤔 (not 100% sure, I’m not experienced in this area).
When I was testing on my hosting, choosing sendmail option didn’t work. I got error about proc_open library which is disabled on shared hosting. With SMTP option, it worked (on that hosting, not on another but that’s probably configuration issue). This is the error:
https://www.dropbox.com/s/37n3fceacfsgqus/Screenshot%202020-12-04%2000.53.43.png?dl=0
it was visible only in debug mode I think, so it may be problem for common users who install Prestashop on hosting without proc_open (order will not be made successfully).
@ web-plus @Lukascisar @ Stampa-Stampa @JeffreyDracoon
http://danielhlavacek.cz/files/177mailfix.zip
- Stáhněte si jej, extrahujte.
- Umístěte tyto soubory do instalace PS.
- Zisk
(volitelný) Dejte mi vědět, jestli to fungujeúsměvPS: @Lukascisar Ahoj, zpráva na další jsem viděl, necháme konverzaci tady.
Great!!! this solution works I tested and my problem is solved!
I think people who are not proficient in php programming like me will really appreciate it.
PS: @Hlavtox super moc děkuji už jsem propadal panice, že budu muset vše z eshopu přesouvat do jiného. Moc děkuji.
Hi there… Maybe upgrading your host plan or changing your host provider is the best thing to do. Setting up your own email service (smtp) is the proper way… Since i setup my own i had no issue and all emails are received and sent problem free (i had some speed issues prior to that maybe was relevant maybe not)
…
I have the same issue and setting correctly the SMTP values DOES NOT work. The test email is not sent and the order email aren’t sent either.
Applying the patch above works using sendmail but is not desirable.
Hello,
I am having the same problem after updating from version 1.7.6.9 to 1.7.7.0. «Error sending e-mail (response code 220)»
@Hlavtox solution works very well, thank you so much.
Hello,
I got mine working on a ionos hosted doing the following.
Mail domain name:
SMTP server: auth.smtp.1and1.fr
SMTP Username: ____@yourdomain.com «You have to have an email address created through ionos hosting»
SMTP password: «your ionos hosted email password»
Encryption: SSL
Port: 465
If it can help someone….
Hello everyone,
As I mentioned above I couldn’t manage to reproduce the issue (see my comment).
For people who are still stuck with this issue, you have three solutions provided by our beloved contributors:
1st solution by @Stampa-Stampa
I am not sure it will help but on one of my customer’s email smtp setup i also had difficulty setting up and in the end the problem was the port. Despite the fast that my customer’s host provider has a card with all the info, the port was not working and in the end he (the customer) was given an alternate one that finally worked..
Check your port, if it’s not working => change it 😉
2nd solution by @Hlavtox
http://danielhlavacek.cz/files/177mailfix.zip
- Download it, extract it.
- Drop these files into your PS installation.
- Profit
(optional) Let me know if it works 😄
Extract the provided solution and enjoy it 😉
3rd solution by @GSafar30
I got mine working on a ionos hosted doing the following.
Mail domain name:
SMTP server: auth.smtp.1and1.fr
SMTP Username: ____@yourdomain.com «You have to have an email address created through ionos hosting»
SMTP password: «your ionos hosted email password»
Encryption: SSL
Port: 465
If it can help someone….
If you encounter this issue with ionos hosted, enjoy his solution 😉
Well, I think I tried my best to summarize the issue,if any contributor could provide more information that helps us reproduce the issue, please help 🙏
Sorry but I have to close this issue and as I said before, when an issue is closed it doesn’t mean that we won’t fix it, but we just don’t have enough information to reproduce it.
if anyone has more informations to reproduce the issue, we will respond ASAP and try to reproduce it ☺️
Thanks for understanding 🙏
Hello @Stampa-Stampa and everyone
As you can see in the screen record below, I had a shop 1.7.5.2 upgraded to 1.7.7.0, I configured my email (STMP) and I tested my email configuration by sending email to myself, I recieve my test email:
https://drive.google.com/file/d/1HXFQqTpfm3o-shFbjq4I-xcOCsaccLTT/view
So, please provide extra infos to understand how we can reproduce your issue.
Thanks!
Hello Everyone.
I had this problem sins long time and finally I think that I found a solution «very simple» …
How did I found this ? I read a lot of experience of people who have to create a new email to configure the Email in PS
and I sow the video that you posted @hibatallahAouadni , than I sow the difference, because in your example and what is happening when you create a new email the password space stays «empty», but not when you have the password in the navigators memory like Chrome, in my case, and I use the same email address to login to my back-office but it’s not the same as my email account, so even when I change and enter my email password it doesn’t works !?
So I erased the password registration from my email adress in Chrome and now the password stays empty when I actualize the page !!!
and now it works, I tested this on 2 websites and it works fine now, so if this can help anyone 
https://www.dropbox.com/s/tx25eq2zhxke436/capture_email_config_ps1.7.8.3.jpg?dl=0
So now just try to find out why with automatic password indicate this doesn’t works ???
Sorry for my English, but I live in France …
Ronald
PS, so the bug Prestashop is that in the block «password», when you enter a new password is replaced by the password that is memorized in the browser !
had this in my apache error.log (about 10 times)
[Fri Mar 04 21:23:52.319674 2022] [authz_core:error] [pid 5146:tid 139859955930880] [client 2a01:e0a:1e5:e640:75fa:25be:9718:95d3:38274] AH01630: client denied by server configuration: /srv/data/web/vhosts/www.xxxxxxxx.fr/htdocs/img/p/1/9/7/5/4/9, referer: https://www.xxxxxx.fr/fr/
Hello, just install a fresh install of Prestashop 1.7.8.7 and emails are not working if we send it to same domain as the shop.
Above solution fixed it, thanks @Hlavtox !
tested on PS 1.7.8.7 .. did not see any change about it on : changelog_1.7.8.8.txt
I attempted the @Hlavtox fix, but it appeared to break my configuration. Sending a test email now reports
Error: Please check your configuration
Sorry if this is very obvious, but does «Drop these files into your PS installation» just mean moving them into the prestashop folder and overwriting the original folders ?
@Hlavtox the same problem as @justbennett mentioned, Error: Please check your configuration , Prestashop 1.7.8.6. mail doesn’t work. Any ideas except smtp?
I attempted the @Hlavtox fix, but it appeared to break my configuration. Sending a test email now reports
Error: Please check your configurationSorry if this is very obvious, but does «Drop these files into your PS installation» just mean moving them into the prestashop folder and overwriting the original folders ?
Yo hice un respaldo de las carpetas y archivos, luego lo eliminé. Por último extraje el contenido del archivo zip en la ubicación original y probé nuevamente. Con eso me funcionó.
Labels
1.7.7.0
Affects versions
Advanced parameters
Component: Which BO section is concerned
BO
Category: Back Office
Bug
Type: Bug
Can’t reproduce
Resolution: issue closed because cannot be reproduced
Label: Which BO under menu is concerned
Topwatchers
Backlog prioritization: issue reported & followed by +6 people
I think I can figure out your problem here. What you need to do is to make a strict setting to comply with the mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Payne Curtis'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
Therefore change your .env to the following;
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abdulkabirojula[email protected]
MAIL_PASSWORD=gjcltiocmmqoutfi
MAIL_ENCRYPTION=tls
MAIL_ENCRYPTION=tls is very essential and needs to be added to the .env file
Related videos on Youtube

04 : 27
Expected response code 220 but got an empty response. Prestashop 1.7
Comze Ecommerce solutions

05 : 06
How to setup free Google SMTP Server | working example

12 : 38
How to setup email configuration and send email in Laravel 5

14 : 49
Laravel 8 Send Email using SMTP

01 : 53
SOLUTION: Expected response code 250 but got code «530»

06 : 46
Failed to authenticate on SMTP server with username | Laravel 8
Comments
-
I am following a tutorial to build an API using passport authentication on enter link description here
I have followed the part 1 and walking through the part 2 with account confirmation and notifications but eventually got a problem when I am testing on POSTMAN. The issue is, it does add to the database only that there is no mail sent with the error. I don’t know of there is any configuration I need to do in .env or mail.php. As I tried to configure the email address, STMP and password. The same error is displayed again and most issues I have seen on here are quite different as most are pertaining to mail.php and .env which I have no idea as there is no such on the tutorial link and I even tried to alter the mail.php and .env, I ran php artisan cache:clear but the same error is displayed.<?php namespace AppNotifications; use IlluminateBusQueueable; use IlluminateNotificationsNotification; use IlluminateContractsQueueShouldQueue; use IlluminateNotificationsMessagesMailMessage; class SignupActivate extends Notification { use Queueable; /** * Create a new notification instance. * * @return void */ public function __construct() { // } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['mail']; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return IlluminateNotificationsMessagesMailMessage */ public function toMail($notifiable) { $url = url('/api/auth/signup/activate/'.$notifiable->activation_token); return (new MailMessage) ->subject('Confirm your account') ->line('Thanks for signup! Please before you begin, you must confirm your account.') ->action('Confirm Account', url($url)) ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ // ]; } }I did also, two ways authentication
Mail.phpreturn [
'driver' => env('MAIL_DRIVER', 'smtp'), 'host' => env('MAIL_HOST', 'smtp.gmail.com'), 'port' => env('MAIL_PORT', 587), 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', '[email protected]'), 'name' => env('MAIL_FROM_NAME', 'Payne Curtis'), ], 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'sendmail' => '/usr/sbin/sendmail -bs', 'markdown' => [ 'theme' => 'default', 'paths' => [ resource_path('views/vendor/mail'), ], ], 'log_channel' => env('MAIL_LOG_CHANNEL'),];
.env
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=userna[email protected] MAIL_PASSWORD=XXXXXXXXXXXXXXX MAIL_ENCRYPTION=null -
Thank you so much… This saves my day. It works like a charm.
Recents
Related
Перейти к контенту
I am following a tutorial to build an API using passport authentication on enter link description here
I have followed the part 1 and walking through the part 2 with account confirmation and notifications but eventually got a problem when I am testing on POSTMAN. The issue is, it does add to the database only that there is no mail sent with the error. I don’t know of there is any configuration I need to do in .env or mail.php. As I tried to configure the email address, STMP and password. The same error is displayed again and most issues I have seen on here are quite different as most are pertaining to mail.php and .env which I have no idea as there is no such on the tutorial link and I even tried to alter the mail.php and .env, I ran php artisan cache:clear but the same error is displayed.
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class SignupActivate extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return IlluminateNotificationsMessagesMailMessage
*/
public function toMail($notifiable)
{
$url = url('/api/auth/signup/activate/'.$notifiable->activation_token);
return (new MailMessage)
->subject('Confirm your account')
->line('Thanks for signup! Please before you begin, you must confirm your account.')
->action('Confirm Account', url($url))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
I did also, two ways authentication
Mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'username@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Payne Curtis'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=XXXXXXXXXXXXXXX
MAIL_ENCRYPTION=null
| Q | A |
|---|---|
| Bug report? | no |
| Feature request? | no |
| RFC? | no |
| How used? | Symfony |
| Swiftmailer version | 6.2.1 |
| PHP version | 7.3.14 |
Observed behaviour
I use Swiftmailer in Laravel to send messages to a mailgun server. It worked fine for the last 6 months, but lately I’ve been encountering errors regarding an empty response. Googling returns answers to what I think is a similar problem («Expected response code 220 but got code «», with message «) but as the message is not the same, I don’t know if it’s the exact same error and the solutions don’t help me. As far as I know Laravel is using TLS as I haven’t changed that setting.
I can’t replicate the error, we send almost 100 mails daily and just a few return this error. Haven’t figured out what fails.
Expected behaviour
The mail should be consistent in succeeding or failing, but it only occurs sometimes.
Example
Can’t reproduce.
Logs
Attached an example log
laravel-2020-04-06.log
Is the problem related to my coding, my mail provider or is it just the package? The problem is happening on a server in production so I don’t want to update just for the sake of it.
We had the same problem. My hoster found the solution. It was the old version of SwiftMailer.
The error we got was:
SymfonyComponentDebugExceptionUndefinedMethodException: Attempted to call an undefined method named "newInstance" of class "Swift_SmtpTransport". at override/classes/Mail.php:714 at MailCore::sendMailTest('1', 'mail.agenturserver.de', 'Dies ist eine Test-Mail. Ihr Server kann nun E-Mails versenden.', 'Test-Nachricht -- PrestaShop', 'text/html', '[Email-Adress]', '[Email-Adress]', '[User-Name]', '[Password]', '465', 'ssl') (src/Adapter/Email/EmailConfigurationTester.php:99) at PrestaShopPrestaShopAdapterEmailEmailConfigurationTester->testConfiguration(array('send_email_to' => '[Email-Adress]', 'mail_method' => '2', 'smtp_server' => 'mail.agenturserver.de', 'smtp_username' => '[Username]', 'smtp_password' => null, 'smtp_port' => '465', 'smtp_encryption' => 'ssl')) (src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php:261) at PrestaShopBundleControllerAdminConfigureAdvancedParametersEmailController->sendTestAction(object(Request)) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151) at SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), 1) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68) at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), 1, false) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200) at SymfonyComponentHttpKernelKernel->handle(object(Request), 1, false) (admin/index.php:82)
We changed following things in the file /overrides/classes/Mail.php:
Old: ## 709 try { 710 if ($smtpChecked) { 711 if (Tools::strtolower($smtpEncryption) === 'off') { 712 $smtpEncryption = false; 713 } 714 $smtp = Swift_SmtpTransport::newInstance($smtp_server, $smtpPort, $smtpEncryption) 715 ->setUsername($smtpLogin) 716 ->setPassword($smtpPassword); 717 $swift = Swift_Mailer::newInstance($smtp); 718 } else { 719 $swift = Swift_Mailer::newInstance(Swift_MailTransport::newInstance()); 720 } 721 722 $message = Swift_Message::newInstance(); 723 724 $message 725 ->setFrom($from) 726 ->setTo($to) 727 ->setSubject($subject) 728 ->setBody($content); 729 730 if ($swift->send($message)) { 731 $result = true; 732 } 733 } catch (Swift_SwiftException $e) { 734 $result = $e->getMessage(); 735 } 736 737 return $result; 738 } ## New: ## 709 try { 710 if ($smtpChecked) { 711 if (Tools::strtolower($smtpEncryption) === 'off') { 712 $smtpEncryption = false; 713 } 714 $smtp = new Swift_SmtpTransport($smtp_server, $smtpPort, $smtpEncryption); 715 $smtp 716 ->setUsername($smtpLogin) 717 ->setPassword($smtpPassword); 718 $swift = new Swift_Mailer($smtp); 719 } else { 720 $swift = new Swift_Mailer(new Swift_MailTransport()); 721 } 722 723 $message = new Swift_Message(); 724 725 $message 726 ->setFrom($from) 727 ->setTo($to) 728 ->setSubject($subject) 729 ->setBody($content); 730 731 if ($swift->send($message)) { 732 $result = true; 733 } 734 } catch (Swift_SwiftException $e) { 735 $result = $e->getMessage(); 736 } 737 738 return $result; 739 } ##
The reason for this error is, ::newInstance doesn´t work anymore in PHP.
Hope, this helps you all!
Для теста настроил в системе программу ssmtp, чтобы проверить как будет уходить почта через почтовый сервер yandex.ru. Настройки следующие:
root=***@yandex.ru
mailhub=smtp.yandex.ru:465
rewriteDomain=yandex.ru
hostname=yandex.ru
AuthUser=***
AuthPass=***
UseTLS=YES
И с этими настройками почта отправляется.
Теперь пробую использовать такие же настройки в Laravel. В файле .env прописано:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yandex.ru
MAIL_PORT=465
MAIL_USERNAME=***
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls
Однако, при отправке почты происходит ошибка:
Swift_TransportException
Connection to tcp://smtp.yandex.ru:465 Timed Out
Я пробовал другие комбинации порта и шифрования, но они тоже не работают:
465, ssl:
Swift_TransportException (553)
Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user. "
587, ssl:
Swift_TransportException
Connection could not be established with host smtp.yandex.ru [ #0]
587, tls:
Swift_TransportException (553)
Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user. "
Вопрос. Как заставить работать почту в Laravel через smtp?
UPD: Еще я пробовал поставить такую настройку:
Все остальные значения MAIL_* приравнял null. Сделал я это
в надежде, что стработает PHP-шная функция mail(), которая у меня работает с помощью настроенного ssmtp. Например, такой код работает:
<?php
mail("sample@gmail.com", "Отправка через SSMTP агента", "Это проверка отправки");
?>
Но после этой настройки и сброса кеша настроек:
$ ./artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
Попытка отправки почты завершается ошибкой:
Swift_TransportException
Expected response code 220 but got an empty response
Example: swift_transportexception expected response code 220 but got an empty response
This problem can generally occur when you do not enable two step verification for the gmail account (which can be done here) you are using to send an email. So first, enable two step verification, you can find plenty of resources for enabling two step verification. After you enable it, then you have to create an app password. And use the app password in your .env file. When you are done with it, your .env file will look something like.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=<<your email address>>
MAIL_PASSWORD=<<app password>>
MAIL_ENCRYPTION=tls
and your mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '<<your email>>', 'name' => '<<any name>>'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
After doing so, run php artisan config:cache and php artisan config:clear, then check, email should work.
Tags:
Misc Example
Related
0
1
Для теста настроил в системе программу ssmtp, чтобы проверить как будет уходить почта через почтовый сервер yandex.ru. Настройки следующие:
root=***@yandex.ru
mailhub=smtp.yandex.ru:465
rewriteDomain=yandex.ru
hostname=yandex.ru
AuthUser=***
AuthPass=***
UseTLS=YES
И с этими настройками почта отправляется.
Теперь пробую использовать такие же настройки в Laravel. В файле .env прописано:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yandex.ru
MAIL_PORT=465
MAIL_USERNAME=***
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls
Однако, при отправке почты происходит ошибка:
Swift_TransportException
Connection to tcp://smtp.yandex.ru:465 Timed Out
Я пробовал другие комбинации порта и шифрования, но они тоже не работают:
465, ssl:
Swift_TransportException (553)
Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user. "
587, ssl:
Swift_TransportException
Connection could not be established with host smtp.yandex.ru [ #0]
587, tls:
Swift_TransportException (553)
Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user. "
Вопрос. Как заставить работать почту в Laravel через smtp?
UPD: Еще я пробовал поставить такую настройку:
Все остальные значения MAIL_* приравнял null. Сделал я это
в надежде, что стработает PHP-шная функция mail(), которая у меня работает с помощью настроенного ssmtp. Например, такой код работает:
<?php
mail("sample@gmail.com", "Отправка через SSMTP агента", "Это проверка отправки");
?>
Но после этой настройки и сброса кеша настроек:
$ ./artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
Попытка отправки почты завершается ошибкой:
Swift_TransportException
Expected response code 220 but got an empty response
За последние 24 часа нас посетили 8872 программиста и 815 роботов. Сейчас ищут 376 программистов …
Отправка писем из Laravel с помощью SMTP через yandex.ru
Тема в разделе «Laravel», создана пользователем xintrea, 3 апр 2019.
-
xintrea
Активный пользователь- С нами с:
- 25 фев 2019
- Сообщения:
- 68
- Симпатии:
- 0
Для теста настроил в системе программу ssmtp, чтобы проверить как будет уходить почта через почтовый сервер yandex.ru. Настройки следующие:
-
mailhub=smtp.yandex.ru:465
И с этими настройками почта отправляется.
Теперь пробую использовать такие же настройки в Laravel. В файле .env прописано:
Однако, при отправке почты происходит ошибка:
-
Connection to tcp://smtp.yandex.ru:465 Timed Out
Я пробовал другие комбинации порта и шифрования, но они тоже не работают:
-
Swift_TransportException (553)
-
Expected response code 250 but got code «553», with message «553 5.7.1 Sender address rejected: not owned by auth user. «
-
Connection could not be established with host smtp.yandex.ru [ #0]
-
Swift_TransportException (553)
-
Expected response code 250 but got code «553», with message «553 5.7.1 Sender address rejected: not owned by auth user. «
Вопрос. Как заставить работать почту в Laravel через smtp?
UPD: Еще я пробовал поставить такую настройку:
Все остальные значения MAIL_* приравнял null. Сделал я это
в надежде, что стработает PHP-шная функция mail(), которая у меня работает с помощью настроенного ssmtp. Например, такой код работает:-
mail(«sample@gmail.com», «Отправка через SSMTP агента», «Это проверка отправки»);
Но после этой настройки и сброса кеша настроек:
-
Configuration cache cleared!
-
Configuration cached successfully!
Попытка отправки почты завершается ошибкой:
-
Expected response code 220 but got an empty response

