0

I created a form that when I submit I get an email. I've used mailtrap and gmail and both of them worked, but when I tried to use my own server email I don't get the email. I know that the code works because I've used it before. I don't know if this played a roll in why it isn't working anymore but I had to reinstall windows on my laptop and reinstall xampp. I also had to change my password that I was using for my server email.

My .env

MAIL_DRIVER=smtp
MAIL_HOST=lin01.hkdns.co.za 
MAIL_PORT=587
MAIL_USERNAME=info@myserver.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=

my mail.php

<?php

return [

    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

    'port' => env('MAIL_PORT', 587),

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'info@myserver.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

    'sendmail' => '/usr/sbin/sendmail -bs',

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

My UsersController store method

public function store()
    {
        $users = new User();

        $input = Input::all();

        $validation = Validator::make($input, User::$rules);

        if($validation->fails()){
            return redirect()->route('admin.users.create')
                    ->withInput()
                    ->withErrors($validation)
                    ->with('message', 'There were validation errors');
        }

        if($validation->passes()){

            $users->name = Input::get('name');
            $users->email = Input::get('email');
            $users->image = Input::get('image');

            $password = $users->generatePassword();

            $users->password = bcrypt($password);

            $data = array(
                    'name' => Input::get('name'),
                    'email' => Input::get('email'),
                    'password' => $password,
                );

            Mail::send('templates::emails.login', $data, function($message){
                $message->to(Input::get('email'), Input::get('name'))->subject('Your login details');
            });

            $users->save();
            $users = User::all();
            return view('users::admin.index', compact('users'));
        }
    }

Also no errors show up in my storage/logs

Isis
  • 189
  • 4
  • 16
  • For sending/receiving mails from your server, there is a need that you must have an email account on that server. Only then, you will be able to send/receive the mails. Did you create the email account on your server? – Saiyan Prince Mar 17 '17 at 07:12
  • yes I did. I just didn't add those details to my question – Isis Mar 17 '17 at 07:34
  • You've censored your details. Could you at least show us which smtp server you're using? There are common issues with gmail, as an example. Also, does your storage/logs tell you anything about the error? What about the php code that calls Mail::send, can you show it to us? – sisve Mar 17 '17 at 07:45
  • just try a gmail account first to see if it works first http://stackoverflow.com/a/32515570/4668162 – Onix Mar 17 '17 at 09:18
  • I have tried gmail and it did work, but when I added my server details it didn't – Isis Mar 17 '17 at 09:53

0 Answers0