-1

I a trying to send an email from localhost to my email but i alwasy get this error

Connection could not be established with host smtp.gmail.com [Une tentative de connexion a �chou� car le parti connect� n�a pas r�pondu convenablement au-del� d�une certaine dur�e ou une connexion �tablie a �chou� car l�h�te de connexion n�a pas r�pondu. #10060] and i didn't found any solution this is a screen shot for the error

this is the controller code

public function contact_sent(Request $request)
{
    $emails = "mohamedfarjallah8@gmail.com";
    $messages = "This body message......";
    $subject = "This is subject from email";
    $fromEmail = "mohamedfarjallah8@gmail.com";

    $data = array('emails'=>$emails,'messages'=>$messages,'fromEmail'=>$fromEmail,'subject'=>$subject);
    Mail::send([],$data, function ($message) use ($data) {
                     $message->from($data['fromEmail'],'SubText that show in header part of email');
                     $message->to($data['emails'])->setBody($data['messages']);
                     $message->subject($data['subject']);
                     $message->replyTo($data['fromEmail'],'Some text you can test this');

            });

            echo "Ok you can check your email";exit;
}

and this is the .env configuration

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=2525
MAIL_USERNAME=mohamedfarjallah8@gmail.com  
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • You have one problem and that's the encoding you're doing for text. In your question, in your screenshot, I see a lot of ���. I am wondering if this could be causing issues as well. – gwally Dec 26 '17 at 22:00

1 Answers1

0

You are using wrong mail port. Port 2525 is for Mailtrap, for Google it should be 587 for MAIL_PORT

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • now it gave me new problem::::::: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\n error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed – Mo'Hamed Farjąlląh Dec 26 '17 at 21:00
  • https://stackoverflow.com/questions/30556773/how-to-fix-stream-socket-enable-crypto-ssl-operation-failed-with-code-1 check if it resolves the SSL issue – 4Jean Dec 27 '17 at 10:07
  • For using gmail id in your project, you have to disable some security from your account. try this link first https://myaccount.google.com/lesssecureapps – Shubham Pokhriyal Dec 27 '17 at 11:19