简体   繁体   中英

500 (Internal Server Error) in Laravel while trying to send Mail in live server

I want to make an online appointment in my Laravel project. For that I have generated a mail function for the appointment.This mail function is working in xammp server locally....But not in live server.

Got this error while trying to send mail

GET http://sencare.com.bd/sencare.com.bd/confirm_appointment?patient_name=test&patient_number=01654&patient_email=rahmanarafat13%40gmail.com&patient_age=8&patient_gender=1&service_id=6&schedule_time_id=1&date=+2018-03-27 500 (Internal Server Error)
send @ jquery-2.1.4.min.js:4
ajax @ jquery-2.1.4.min.js:4
n.(anonymous function) @ jquery-2.1.4.min.js:4
(anonymous) @ (index):2029
dispatch @ jquery-2.1.4.min.js:3
r.handle @ jquery-2.1.4.min.js:3

log file error

ERROR: Connection could not be established with host mail.mailhost.com [php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution #0] {"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host mail.mailhost.com [php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution #0] at /home2/sencarec/public_html/sencare.com.bd/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:269)

Mail function code inside controller

public function sendMail($emailDataArray)
{
 \Mail::send('frontend.mail.demo', $emailDataArray, function($message) use ($emailDataArray)
  {
    $message->to($emailDataArray['patient_email'], 'Test')->subject('APPOINTMENT');
  });
}

Here is my .env file's MAIL part

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=shetshuvro@gmail.com
MAIL_PASSWORD="app generated password"
MAIL_ENCRYPTION=tls

Anything change needed for live server or what's the problem actually ?

Solved this problem.

Just change the driver name in .env file from smtp to sendmail

'driver' => 'sendmail',

reference [ Using gmail smtp via Laravel: Connection could not be established with host smtp.gmail.com [Connection timed out #110]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM