send email testing fake data in browser

Viewed 77

I want to do email testing send fake data for partner registration. I create another route and another method in Backend\DevelopentController.php and in web.php to run in the browser. when I run in the browser I get an error Class

'App\Helpers\General\MailHelper\Route' not found

below is my code:

web.php

namespace App\Helpers\General\MailHelper; 

use App\Http\Controllers\LanguageController;
use App\Http\Controllers\Backend\DevelopmentController;
use App\Helpers\General\MailHelper;    

Route::get('/email/register-partner',  'Backend\DevelopmentController@register_partner');

controllers\Backend\DevelopmentController.php

namespace App\Http\Controllers\Backend;
namespace App\Helpers\General\MailHelper;

public function register_partner() {
    $data = array(
        'name' => 'fake name',
        'companyName' => 'berjaya Corp',
        'contact__person' => '01202132',
        'email' => 'partner@gmail.com'
    );

    (new MailHelper)->partner_registration('partner@gmail.com', $data);
}

MailHelper.php

namespace App\Helpers\General;

public function partner_registration($email,$data) {
    $lMessage1 = '<p>Dear <strong>'.$data['name'].'</strong>,</p>
    <p>Thank you for registering with us. You are just one step away to register successfully,
    please attach a document as reference to be related with your nature of business. Click <a href="'.url('agency/upload/info').'/'.$data['resetCode'].'"> here </a>
    to attach.</p>
    <ol>
        <li>Motor dealer : business name card</li>
        <li>Insurance agent / agency : Agent Identity Card or business name card</li>
    </ol>
    <p style="color:#000;">
        <ul style="list-style:none;">
            <li>Company Name : '.ucwords($data['companyName']).'</li>
            <li>Contact Person : '.$data['contact_person'].'</li>
            <li>Contact  : +60'.$data['contact'].'</li>
            <li>Email : '.$data['email'].'</li>
        </ul>
    </p>
    <p>
        You will receive another email from us after your registration has been approved.
    </p>
    <br/>
    <p>Thank You, <br/>Example Partner Program Administration</p>
    <p>Website <a href="http://www.example.com">http://www.example.com</a><br/>
    Tel : +6014243242</p>
    <p style="color:grey;font-size:8pt;">IMPORTANT NOTICE OF DISCLAIMER</p>
    <p style="color:grey;font-size:8pt;">
        The information in this email and any attachments is intended only for the person or entity to which it addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination, or other of, taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please delete the message and any attachments and notify the sender of misdelivery
        Any views expressed by an individual within this e-mail do not necessarily reflect the view(s) of example Sdn. Bhd. and shall include but not limited to all of its subsidiaries and associated companies
    </p>';

    $subject = 'Your online registration has been submitted successfully';
    $params['data'] = $lMessage1;
    $params['to_email'] = $email; //required
    $params['template_type'] = 'markdown';  //default is view
    $params['template'] = 'emails.app-mailer'; //path to the email template
    $params['subject'] = $subject; //optional
    $params['from_email'] = config('mail.from.address');
    $params['from_name'] = config('mail.from.name');

    try {
        sendmail($params);

    } catch (Exception $e) {
        Log::alert('Partner Registration User Email failed');
    }
}
1 Answers

1st step Now you have to replace this line

use App\Helpers\General\MailHelper;

into

use MailHelper;

now run and check it

2nd step

also replace this line

(new MailHelper)->partner_registration('partner@gmail.com', $data);

into

(new \MailHelper)->partner_registration('partner@gmail.com', $data);

then run command composer dump-autoload

i hope you got your solution .

Related