我试图在Laravel中发送一封非常基本的电子邮件,但是from字段无效。它不是来自寄件人的寄回地址,而是寄回地址和姓名。
我的.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=chris@listingnaples.com
MAIL_PASSWORD=mypass;
MAIL_ENCRYPTION=tls
我的控制器有:
public function sendEmail(ShowingPageContactRequest $request) {
// email me custom email
$data = $request->all();
Mail::send('emails.propertyemail', $data, function ($message) use ($data) {
$message->subject('Property Query from ' . $data['name'])
->sender($data['email'], $data['name'])
->from($data['email'], $data['name'])
->to('chris@listingnaples.com')
->replyTo($data['email'], $data['name']);
});
}
dd($ data)显示:
array:6 [▼
"_token" => "ZSvuhAhkCetDFZOrQMtbDHBy2RfzECGFT03wixt3"
"MLSNumber" => "216003681"
"name" => "John Doe"
"email" => "jdoe@gmail.com"
"phone" => "(239) 555-1212"
"comments" => "This is my comment or question."
]
所以电子邮件就在那里,John Doe就在那里。但是,当我检查我的电子邮件时,它说它来自John Doe但是chris@listingnaples.com!
我的邮件配置文件甚至包含:
'from' => ['address' => null, 'name' => null],