Failed to authenticate on SMTP server with username "hello@example.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Authentication failed".".
// below is the .env file and the email sender screen file MAIL_MAILER=smtp MAIL_HOST=smtp.mailgun.org MAIL_PORT=587 MAIL_USERNAME=hello@example.com MAIL_PASSWORD=mypassword MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS="hello@example.com" MAIL_FROM_NAME="${APP_NAME}"
//the email sender screen code
<?php namespace App\Orchid\Screens; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Mail\Message; use Illuminate\Support\Facades\Mail; use Orchid\Screen\Fields\Input; use Orchid\Screen\Fields\Quill; use Orchid\Screen\Fields\Relation; use Orchid\Support\Facades\Layout; use Orchid\Screen\Actions\Button; use Orchid\Screen\Screen; use Orchid\Support\Facades\Alert; class EmailSenderScreen extends Screen { /** * Query data. * * @return array */ public function query(): array { return [ 'subject' => date('F').' Campaign News', ]; } /** * Display header name. * * @return string|null */ public function name(): ?string { return 'Send Mail'; } public function description (): ?string { return 'Sending Mail From Within'; } /** * Button commands. * * @return \Orchid\Screen\Action[] */ public function commandBar(): iterable { return [ Button::make('Send Message') ->icon('paper-plane') ->method('sendMessage') ]; } /** * Views. * * @return \Orchid\Screen\Layout[]|string[] */ public function layout(): array { return [ Layout::rows([ Input::make('subject') ->title('recipients') ->required() ->placeholder('The message subject line') ->help('enter the subject line for your message'), Relation::make('users.') ->title('recipients') ->multiple() ->required() ->placeholder('Email addresses') ->help('Enter the users that you would like to send this message to.') ->fromModel(User::class,'name','email'), Quill::make('content') ->title('Content') ->required() ->placeholder('Inset the text here...') ->help('Add the content for the message that you would like to send.') ]) ]; } public function sendMessage(Request $request) { $request->validate([ 'subject' => 'required|min:6|max:50', 'users' => 'required', 'content' => 'required|min:10' ]); Mail::raw($request->get('content'), function (Message $message) use ($request) { $message->from('hello@example.com'); $message->subject($request->get('subject')); foreach ($request->get('users') as $email) { $message->to($email); } }); Alert::info('Your email message has been sent successfully.'); } }The error message is self-explanatory. Your MAIL_USERNAME
and/or MAIL_PASSWORD
are probably wrong.
Which part exactly my .env file is in the code above can you help this error is really stressing me out
You are missing the MAIL_ENCRYPTION=null
value. Use SSL or TLS encryption based on your server configuration.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community