Laravel Email Contact

Laravel Email Contact

  1. Email Config

    1. Config

    2. Email Send Validate

  2. Router

  3. View

    • Origin Post Way

    • Bower / Gulp Integrate

  4. Controller

    • Request - Validate input

    • Session - Success Alert

  5. AJAX

    1. Submit 500 Bug

    2. JSON Response

1. Email Config

  1. .env & config/email

  2. php artisan tinker (Test Validate)

    Mail::send("emailtemplate", ["name" => "robin"], 
    function($message) { $message->to("xlcoder166@gmail.com")
    ->subject("Say Hello Laravel");
    });
    

2. Router

  1. Add get Index Show

  2. Add post mail send

        Route::get('/', "ContactContoller@index" );
        Route::post("/", "ContactContoller@sendMail");
    

3. view

  1. Pass Variable Blade

  2. Error Usage

  3. Session Usage

  4. Bower / Glup

    1. Bower - bower_vendor in public

    2. glup use origin glup package.json and gulp plug

          @if (count($errors) > 0)
            <div class="alert alert-danger">
              <strong>Whoops!</strong>
              There were some problems with your input.<br><br>
              <ul>
                @foreach ($errors->all() as $error)
                  <li>{{ $error }}</li>
                @endforeach
              </ul>
            </div>
          @endif
      
  5. Hmtl Form Post/Get Mothed

4. Controller

  1. Add Email Function & Validate Request

    • Illuminate\Support\Facades\Mail - config/App

  2. Reuest

    1. function rule validate rule

    2. custom error message

5. AJAX

  1. Right Submit & Fix 500 bug

    <meta name="csrf-token" content="{{ csrf_token() }}">
    
    $.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
    });
    
    
  2. Controller Use Illuminate\Support\Facades\Response; return json response

    return Response::json(["status" => "success"]);
    

标签: none

已有 2 条评论

  1. Just wanted to ask if you would be interested in getting external help with graphic design? We do all design work like
    banners, advertisements, brochures, logos, flyers, etc. for a fixed monthly fee.

    We don't charge for each task. What kind of work do you need on a regular basis? Let me know and I'll share my portfolio
    with you.

  2. ad ad

    Get thousands of clicks per month from Google, Bing and other search engines from as low as $299 per month.
    No SEO and no PPC.
    Flat fee per keyword.
    Send list of desired keywords and I'll send you traffic quote and details within 24 hours.
    You can also visit our website and see online demonstration.

添加新评论