示例 <hello@example.com> 不断发送电子邮件

Emails keep being sent from Example <hello@example.com>

已经读了很多书,甚至 php artisan config:clear 检查了所有文件,hello@example.com 不存在。

它适用于本地 w/o 个问题。

此外,还有另一个使用 PHPMailer 的 PHP 应用程序,但没有发生此问题,所以我认为这与服务器无关。

感谢任何帮助,因此此脚本只等待此问题得到解决,以便它可以上线。


UPDATE: The issue was with the mail server. We changed the mail server to a different machine but didn't configure completely the DNS.

Thanks to both for answering.

电子邮件地址在 config/mail.php 文件中配置

'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
    'name' => env('MAIL_FROM_NAME', 'Example'),
],

但是您如何查看它是使用在根目录中的 .env 中配置的环境变量

MAIL_FROM_ADDRESS=info@blabla.com.ar
MAIL_FROM_NAME="San Marino Pastas"

请记住,如果您使用的是 artisan serve 或 queue listining,请重新启动服务以采用新配置。

请试试这个,让我知道它是如何工作的:)

1)首先你要在.env文件中设置环境变量

MAIL_DRIVER=mail
MAIL_HOST=mail.abc.com
MAIL_PORT=465
MAIL_USERNAME=info@abc.com
MAIL_PASSWORD=abc123
MAIL_ENCRYPTION=null

2) 然后将其导入您的控制器,

use Illuminate\Support\Facades\Mail;

3) 然后在你的controller中添加这个函数,

public function basic_email() {
  $data = array('name'=>"Virat Gandhi");
  Mail::send(['text'=>'mail'], $data, function($message) {
        $message->from('info@abc.com');
        $message->subject('Testing');
        $message->to('abc@gmail.com'); 
 echo "Basic Email Sent. Check your inbox.";
    });

4) 希望对您有所帮助。