Change address to email and it should work
Mail::to(
[
'name' => 'Joe Schmoe',
'email' => '[email protected]'
]
)->send(new ContactForm());
Is it possible to use Laravel's Mail:to without actually passing it a database user or even having a database?
I just have a super small site I want to build out a contact form on. Wondering if there is a way to do this or if I'm doing something wrong before just breaking down and using SQLite.
My SendEmail.php Controller.
<?php
namespace App\Http\Controllers;
use App\Mail\ContactForm;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class SendEmail extends Controller
{
public function send() {
Mail::to(
[
'name' => 'Joe Schmoe',
'address' => '[email protected]'
]
)->send(new ContactForm());
}
}
When I try the above code, I get this...
Swift_RfcComplianceException
Address in mailbox given [Joe Schmoe] does not comply with RFC 2822, 3.6.2.
https://mywebsite.test/testemail
Hide solutions
Database name seems incorrect
You're using the default database name laravel. This database does not exist.
Edit the .env file and use the correct database name in the DB_DATABASE key
READ MORE
Database: Getting Started docs
Well... this isn't the answer to what I asked, but it is the answer to the problem...
https://laravel.com/docs/6.x/mail#mail-and-local-development
In this section it shows how you can create a config area for the to address.
After doing that I can simply use...
Mail::send(new ContactForm());
That is all I really wanted to do, was to have the contact form always send to one user.
Please or to participate in this conversation.