php 预期响应代码 250,但得到代码“”,消息为“”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31133301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:16:25  来源:igfitidea点击:

Expected response code 250 but got code "", with message ""

phpemaillaraveloutlook

提问by Primecore

I can send my emails in localhost flawlessly. but ever since I uploaded my program into a hosting site I get this error

我可以完美地在本地主机中发送我的电子邮件。但是自从我将程序上传到托管站点后,我收到此错误

Expected response code 250 but got code "", with message ""

预期响应代码 250,但得到代码“”,消息为“”

I also updated the .envfile.

我也更新了.env文件。

MAIL_DRIVER=smtp

MAIL_HOST=smtp-mail.outlook.com

MAIL_PORT=587

[email protected]

MAIL_PASSWORD=123456789

works in localhost but not in the hosting site.

在 localhost 中工作,但不在托管站点中工作。

i am using laravel 5

我正在使用 Laravel 5

采纳答案by Primecore

回答by cyber8200

I ran through this error so many times for some reasons.

由于某些原因,我多次遇到此错误。

When see this error,

当看到这个错误时,

Expected response code 250 but got code “”, with message “”

预期响应代码 250,但得到代码“”,消息为“”

Please triplecheck your email password.

三重检查您的电子邮件密码。

Note :Test your credentals first on a phone app or log-in into the mail site. If pass, you may update in your .envfile

注意:首先在电话应用程序上测试您的凭据或登录邮件站点。如果通过,您可以在您的.env文件中更新

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=****


If you know for surethat your password is correct.

如果您确定您的密码是正确的。

Check to make sure your Gmail or Yahoo Mail allow app log-in.

检查以确保您的 Gmail 或 Yahoo Mail 允许应用登录。

Example

例子

Yahoo

Yahoo

enter image description here

在此处输入图片说明

回答by Rentheitroad Reis

we solved this problem by clearing the Laravel's configuration cache

我们通过清除 Laravel 的配置缓存解决了这个问题

php artisan config:clear

php artisan config:clear

回答by mpalencia

This one worked for me, 'if you are using GMAIL'

这个对我有用,'如果你使用 GMAIL'

  1. Go to 'My Accounts'
  2. Go to 'Sign-in & security'
  3. Scroll down to 'Allow less secure apps'
  4. Switch #3 to ON
  1. 转到“我的帐户”
  2. 转到“登录和安全”
  3. 向下滚动到“允许安全性较低的应用程序”
  4. 将 #3 切换到 ON

After doing this and if you just recently set up your email configurations on laravel and still doesn't work, try running:

执行此操作后,如果您最近在 laravel 上设置了电子邮件配置,但仍然无法正常工作,请尝试运行:

php artisan config:cache

回答by Rejaul

I've a working laravel swiftmailer using google server. Here my steps:

我有一个使用谷歌服务器的工作 laravel swiftmailer。这是我的步骤:

  1. I visited the link https://www.google.com/settings/security/lesssecureappsand turned on less secure apps.
  2. I edited .env file as like below:

    MAIL_DRIVER=smtp

    MAIL_HOST=smtp.gmail.com

    MAIL_PORT=587

    MAIL_USERNAME=username //i.e. [email protected]

    MAIL_PASSWORD=password //Gmail accounts password

    MAIL_ENCRYPTION=ssl

  1. 我访问了链接 https://www.google.com/settings/security/lesssecureapps并打开了安全性较低的应用程序。
  2. 我编辑了 .env 文件,如下所示:

    MAIL_DRIVER=smtp

    MAIL_HOST=smtp.gmail.com

    MAIL_PORT=587

    MAIL_USERNAME=username //即 [email protected]

    MAIL_PASSWORD=password //Gmail 账户密码

    MAIL_ENCRYPTION=ssl

Edit username and password with your own.

使用您自己的用户名和密码编辑。

  1. In my controller, I wrote the following code:

    $rawData = request::all();

    Mail::queue('program.meeting.emailInvite', $rawData, function($message) use ($rawData)

    {

    $message->from('[email protected]', 'Echosofts')->to(array_map('trim', explode(',', $rawData['all_email_id'])))->subject($rawData['mail_title']);

    });

  1. 在我的控制器中,我编写了以下代码:

    $rawData = request::all();

    Mail::queue('program.meeting.emailInvite', $rawData, function($message) use ($rawData)

    {

    $message->from('[email protected]​​om', 'Echosofts')->to(array_map('trim',explode(',', $rawData['all_email_id']))->subject($rawData ['mail_title']);

    });

Then email was working fine except the sender email ID was my google account ([email protected]) instead of [email protected].

然后电子邮件工作正常,除了发件人电子邮件 ID 是我的 google 帐户 ([email protected]) 而不是 [email protected]​​om。

  1. To overcome the sender email changing problem, I visited my google account and did the following:
  1. 为了克服发件人电子邮件更改问题,我访问了我的 google 帐户并执行了以下操作:

"Setting icon"-> Settings -> Accounts and Import->Send mail as->Add another email address your own.

“设置图标”-> 设置-> 帐户和导入-> 将邮件发送为-> 添加您自己的另一个电子邮件地址。

The following settings depends on your configuration.

以下设置取决于您的配置。

    Email address: [email protected]
    SMTP server: mail.echosofts.com
    Username: [email protected]
    password:**********
    Port:25

回答by phirschybar

FWIW - I get this error when sending a email with an empty string in the tofield.

FWIW - 在to字段中发送带有空字符串的电子邮件时出现此错误。