Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel通过SMTP发送电子邮件在Azure上失败,本地环境工作正常_Php_Laravel_Azure_Email_Swiftmailer - Fatal编程技术网

Php Laravel通过SMTP发送电子邮件在Azure上失败,本地环境工作正常

Php Laravel通过SMTP发送电子邮件在Azure上失败,本地环境工作正常,php,laravel,azure,email,swiftmailer,Php,Laravel,Azure,Email,Swiftmailer,我正在开发一个Laravel应用程序,我需要使用不同的设置来发送电子邮件(这样用户就可以用自己的电子邮件发送消息)。我已经设置好了,它现在运行良好——但是,仅在本地主机测试环境中。当我移动到生产服务器(Azure VM)时,总是会出现相同的错误: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required 不管我使用什么端口和加密类型 这就是我在自定义邮件中所做的:

我正在开发一个Laravel应用程序,我需要使用不同的设置来发送电子邮件(这样用户就可以用自己的电子邮件发送消息)。我已经设置好了,它现在运行良好——但是,仅在本地主机测试环境中。当我移动到生产服务器(Azure VM)时,总是会出现相同的错误:

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
不管我使用什么端口和加密类型

这就是我在自定义邮件中所做的:

<?php

namespace App\Mail;
use Illuminate\Http\Request;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Repositories\Email;

class DemoEmail extends Mailable
{
  use Queueable, SerializesModels;

  public $email;
  public $request;

  public function __construct()
  {

  }
  public function build(Email $email,Request $request)
  {

    $this->email = $email;
    $this->request= $request;
    $usrsettings = $this->email->settings();

    $conf = [
      'driver' => 'smtp',
      'host' => $usrsettings["Servidor"],
      'port' => $usrsettings["Puerto"],
      'from' => [
        'address' => $usrsettings["Direccion"],
        'name' => $usrsettings["Nombre"],
      ],
      'encryption' => $usrsettings["encrypt"],
      'username' => $usrsettings["Cuenta"],
      'password' => $usrsettings["Contraseña"],
    ];

    \Config::set('mail',$conf);

    if (isset($request['cc']) && $request['cc']!=null) $this->cc($request['cc']);
    if (isset($request['bcc']) && $request['bcc']!=null) $this->bcc($request['bcc']);

    return $this->from($conf["from"]["address"],$conf["from"]["name"])
                ->subject($request["subject"])
                ->view('emails.crm');
  }
}

我想这可能是由于您的生产服务器IP被列入黑名单或需要身份验证才能发送邮件造成的

我刚刚遇到了一个与新服务器类似的问题-为了发送邮件,只有一个SPF记录,但没有适当的身份验证,IP需要建立起来并赢得声誉


我希望经过几个月在我的网站上发送带有身份验证的邮件后,我应该能够发送邮件,而不必每次都设置SMTP服务器、用户名和密码

为了安全和潜在的误用,这些服务的端口在VM实例上被阻止。您需要手动取消阻止它们


更好的方法是使用外部服务处理电子邮件,如SendGrid或MailGun,但这不是强制性的

谢谢你的意见。然而,coleague刚刚在同一台服务器上的桌面应用程序上进行了测试,测试结果没有问题。所以我无法想象这与IP被列入黑名单有什么关系=/我真的完全迷路了。谢谢你的评论。我们确实考虑过,但是,我们有一个桌面应用程序,基本上和电子邮件客户端做同样的事情,并且顺利完成。我想知道这种阻塞是否只发生在php或类似的东西上=/