0

Below are my mail code and configuration. The issue which I'm facing is that mail() is not working, but I'm getting the output as mail sent (from code,when 'pretend' => false,) and not sent ('pretend' => true, and I also get "server.INFO: Pretending to mail message to:soandso@mail.com " in the log file ).What could be the issue? Same code is working for another site hosted with the same provider( GoDaddy)

$mail= Mail::send($view, $data, function ($message) use ($email, $subject, $data) {

            if (isset($data['senderEmail'])) {

                $message->from($data['senderEmail'], $data['senderFullname']);
            }else{
                $defult=\DB::table('settings')->select('value')->where('option','=','defaultMail')->first();
                $message->from($defult->value, 'mailFrom');
            }
            if (isset($data['attachment'])) {
                $message->attach($data['attachment']);
            }
            $message->to($email)->subject($subject);
        });
        if($mail){
          dd("mail sent");
        }else{
          dd("not sent");
        }

.env file

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=XXXXXXXX@gmail.com
MAIL_PASSWORD="XXXXXXXX"
MAIL_ENCRYPTION=tls

SENDERS_EMAIL=XXXXXXXX@gmail.com
SENDERS_NAME=afsal

config/mail.php

'sendmail'   => '/usr/sbin/sendmail -bs',
 'pretend'    => false,
Afsal
  • 1
  • 4
  • Are you sending email through gmail or sendmail, and where's the rest of your mail file? – James Nov 28 '16 at 07:37
  • mail is send through Gmail, if I use MAIL_DRIVER= SMTP, it throws an error ('Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection refused #111]'). The mail file is in view/emails folder(the path to the file is in $view) – Afsal Nov 28 '16 at 07:48
  • The SMTP driver is what you need to use. Looks like the error you are getting has been explained here. http://stackoverflow.com/a/14179075/1739852 – James Nov 28 '16 at 07:52
  • Thanks. I'll check this and update shortly. – Afsal Nov 28 '16 at 08:12
  • MAIL_DRIVER in this case should be smtp – Khan Shahrukh Nov 28 '16 at 09:11

0 Answers0