I am trying to create a Contact Us Form in a Laravel Project but ran into the following error and would like to know how to solve this.
Expected response code 354 but got code "503", with message "503-All RCPT commands were rejected with this error: 503-"Your IP: 202.133.88.147 : Your domain gmail.com is not allowed in header 503-From" 503 Valid RCPT command must precede DATA "
The following is my .ENV file
MAIL_DRIVER=smtp
MAIL_HOST=mail.mydomain.com
MAIL_PORT=26
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null
Controller
public function contactus()
{
return view('contactus');
}
public function sendContactMail(Request $request)
{
Mail::to('[email protected]')->send(new ContactUs($request));
Session::flash('success','Message Sent Successfully!');
return redirect()->back();
}
ContactUs.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class ContactUs extends Mailable
{
protected $contactdata;
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(\Illuminate\Http\Request $request)
{
$this->contactdata = $request;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from($this->contactdata->email)
->subject($this->contactdata->subject)
->with([
'message' => $this->contactdata->message,
'fullname' => $this->contactdata->first_name.' '.$this->contactdata->last_name
])
->markdown('emails.contactus');
}
}
Thanks in advance for the help.
MAIL_ENCRYPTION
setting should beMAIL_ENCRYPTION=
instead ofMAIL_ENCRYPTION=null
. – VoluminousMAIL_ENCRYPTION=
? – VoluminousMAIL_ENCRYPTION=
also. same result. – Teresiateresina587
port withtls
encryption. Also your account needs to be either a Gmail account or a GSuite email account. – Voluminous