1
votes

I want to send a mail to the company's office mail(other than email field for login) when a candidate appy for the job posting

Controller function

public function ImmediateApply(Request $request) {
    try {
        $request['resume'] = $this->image->uploadImage($request->resume, 'resumes');
        if (ImmediateApply::where('job_post_id', '=', $request->job_post_id)->where('email', '=', $request->email)->count() == 0) {
            $application = ImmediateApply::create($request->all());
            $job = JobPost::find($request->job_post_id);
            $company = Company::find($job->company_id);
            $company->notify(new JobApplication($job));
            return response()->json([
                'message' => 'You have applied successfully',
                'code' => '201']);
        }
    } catch (Exception $e) {
        return response()->json([
            'message' => $e->getMessage(),
            'code' => 400,
        ], 400);
    }
}

company model

public function routeNotificationForMail() {
    return $this->office_mail;
}

Now I'am getting the error

1.Failed to authenticate on smtp server with username "x" using 2 possible authenticators

2.CredentialsException in InstanceProfileProvider.php line 79: Error retrieving credentials from the instance profile metadata server. (Error creating resource: [message] fopen(http://169.254.169.254/latest/meta-data/iam/security-credentials/): failed to open stream: Connection timed out [file] /var/www/html/jobs-website/laravel5.4/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 312)

But when i check in smtp online test, I'am recieving the mail correctly

1
Check your user name and password - Govind Samrow

1 Answers

0
votes

Actually i don't know the reason for the 1st error.It doesn't persist now. Changing

MAIL_DRIVER = ses

from

MAIL_DRIVER = smtp

solved the 2nd error. now everything working fine.