Ejemplo n.º 1
0
 /** @test */
 public function it_raises_an_exception_when_a_custom_client_is_not_registered_in_the_container()
 {
     $this->expectException('ReflectionException');
     $this->expectExceptionMessage('Class mailgun.client does not exist');
     unset($this->app['mailgun.client']);
     Mailgun::send(null, null, null);
 }
Ejemplo n.º 2
0
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(MenuWasPublished $event)
 {
     $menu = $event->menu;
     $approvedUsers = User::getApprovedUsers();
     $allUsers = $approvedUsers->lists('email')->toArray();
     $userVars = $approvedUsers->map(function ($user) {
         return [$user->email => ['name' => $user->name]];
     })->collapse()->toArray();
     $data = ['menu' => $menu];
     \Mailgun::send('emails.menu-was-published', $data, function ($m) use($menu, $allUsers, $userVars) {
         $m->to($userVars)->subject('New Menu for ' . $menu->date->format('d.m.Y'));
         // $m->recipientVariables($userVars);
     });
 }
Ejemplo n.º 3
0
 public function sendEmail()
 {
     $rules = ['email' => 'required|email'];
     $input = Input::only('email');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $names = ["Tim", "Tom", "James Bond", "Peter Pan"];
     $name = $names[rand(0, count($names) - 1)];
     $data = ["name" => $name];
     \Mailgun::send("emails.hello", $data, function ($message) {
         $message->to(Input::get("email"), "hurr")->subject("hi");
     });
     return View::make("mailissend", $data);
 }
 public function send_new_pass()
 {
     try {
         $email = Input::get('request_pass_email');
         $user = User::whereEmail($email)->first();
         $link = URL::to('dashboard/' . $this->hashids->encrypt($user->id) . '/reset-pass-from-email');
         $name = $user->first_name . ' ' . $user->last_name;
         $data = ['user' => $user, 'link' => $link];
         $result = Mailgun::send('backend.emails.auth.click-to-reset-pass', $data, function ($message) use($user, $name) {
             $message->from($this->admin->email, $this->admin->first_name)->subject($this->setting->sitename . ' Admin Password Reset')->to($user->email, $name)->tag('Password Recovery');
         });
         if (is_object($result)) {
             return Response::json(['success' => 'An email has been sent to you with instructions on how to reset your password.']);
         } else {
             return Response::json(['error' => 'An error was encountered sending the email. Please try again or contact server admin.']);
         }
     } catch (Exception $e) {
         return Response::json(array('error' => 'An error occurred. Kindly try again or contact admin.'));
     }
 }
Ejemplo n.º 5
0
<?php

Route::get('emailBatch', function () {
    $data = array();
    Mailgun::send('emails.emailBatch', $data, function ($message) {
        $message->to(array("Daniel Heyman <*****@*****.**>" => array('name' => 'Hello', 'code' => 'poop'), "Dan Heyman <*****@*****.**>" => array('name' => 'Bananna', 'code' => 'cdf')))->subject('Welcome to BriskSurf!');
    });
    return 'hello';
});
Ejemplo n.º 6
0
Route::group(['middleware' => ['web']], function () {
    require __DIR__ . '/Routes/front.php';
    require __DIR__ . '/Routes/auth.php';
    Route::get('sesiones', [function () {
        dd(Session::get('cart'));
    }, 'as' => 'sesiones']);
});
Route::group(['prefix' => 'admin', 'middleware' => ['admin']], function () {
    require __DIR__ . '/Routes/admin.php';
});
Route::get('mailjk', [function () {
    $user = [];
    $m = Mailgun::send('emails.focusGroup', $user, function ($message) {
        $message->to('*****@*****.**')->subject('Invitacion focus group Agrosellers');
        $message->tag('testGroupAgro');
        $message->from('*****@*****.**', 'Agrosellers');
        $message->trackOpens(true);
    });
    dd($m);
}, 'as' => 'sesiones']);
use Agrosellers\User;
Route::get('prueba', ['as' => 'elasticIndex', 'uses' => 'PositionAlgorithmController@index']);
use Illuminate\Http\Request;
use Agrosellers\Entities\Product;
Route::post('prueba', ['as' => 'elasticSearch', 'uses' => function (Request $request) {
    Product::addAllToIndex();
    $products = Product::search($request->name)->getDictionary();
    echo '<table>
                <thead>
                    <tr>
                        <th>Nombre</th>
 public function send()
 {
     $inputs = [];
     foreach (Input::all() as $key => $input) {
         $inputs[$key] = Jamesy\Sanitiser::trimInput($input);
     }
     $rules = Input::has('save_draft') ? $this->draftRules : $this->rules;
     $validation = Jamesy\MyValidations::validate($inputs, $rules);
     if ($validation != NULL) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         if (Input::has('save_draft')) {
             $draft = Input::has('was_draft') ? Draft::find(Input::get('was_draft')) : new Draft();
             $draft->user_id = $this->user->id;
             $draft->tag_id = $inputs['tag_id'];
             $draft->subject = $inputs['subject'];
             $draft->email_body = $inputs['email_body'];
             $draft->save();
             return Redirect::to('dashboard/emails/drafts');
         } else {
             $maxSendNum = 999;
             $email = new Email();
             $email->user_id = $this->user->id;
             $email->tag_id = $inputs['tag_id'];
             $email->from = Setting::getFromName($this->user) . " (" . Setting::getFromEmail($this->user) . ")";
             $email->reply_to = Setting::getFromName($this->user) . " (" . Setting::getReplyToEmail($this->user) . ")";
             $email->subject = $inputs['subject'];
             $email->email_body = $inputs['email_body'];
             $email->save();
             $maillists = Input::has('mail_lists') ? $inputs['mail_lists'] : [];
             $emails = Input::has('subscribers') ? $inputs['subscribers'] : [];
             $selectedSubs = Subscriber::getSelectedSubscribersForEmail($maillists, $emails);
             while (count($selectedSubs)) {
                 $data = ['email_body' => $inputs['email_body'], 'email_id' => \Jamesy\Miscellaneous::encryptId($email->id)];
                 $variables = [];
                 $tag = Tag::find($inputs['tag_id']);
                 $emailId = $email->id;
                 $numToSlice = count($selectedSubs) > $maxSendNum ? $maxSendNum : count($selectedSubs);
                 $subscribers = $numToSlice < count($selectedSubs) ? array_slice($selectedSubs, 0, $numToSlice) : $selectedSubs;
                 foreach ($subscribers as $subscriber) {
                     $variables[$subscriber['email']] = ['id' => $subscriber['id'], 'first_name' => $subscriber['first_name'], 'last_name' => $subscriber['last_name']];
                 }
                 $result = Mailgun::send('backend.emails.send_templates.main', $data, function ($message) use($subscribers, $inputs, $variables, $emailId, $tag) {
                     $message->from(Setting::getFromEmail($this->user), Setting::getFromName($this->user))->replyTo(Setting::getReplyToEmail($this->user), Setting::getFromName($this->user))->subject($inputs['subject']);
                     foreach ($subscribers as $subscriber) {
                         $message->to($subscriber['email'], $subscriber['first_name'] . ' ' . $subscriber['last_name']);
                     }
                     $message->recipientVariables($variables);
                     $message->tag($tag->name);
                 });
                 if (is_object($result)) {
                     if ($result->http_response_code == 200) {
                         foreach ($subscribers as $subscriber) {
                             $apicall_id = explode('<', explode('@', $result->http_response_body->id)[0])[1];
                             $analytic = new Analytic();
                             $analytic->subscriber_id = $subscriber['id'];
                             $analytic->email_id = $email->id;
                             $analytic->recipient = $subscriber['email'];
                             $analytic->apicall_id = $apicall_id;
                             $analytic->status = 'queued';
                             $analytic->save();
                         }
                     }
                 }
                 $selectedSubs = array_slice((array) $selectedSubs, $numToSlice);
             }
             if (Input::has('was_draft')) {
                 Draft::find(Input::get('was_draft'))->delete();
             }
             return Redirect::to('dashboard/emails/sent');
         }
     }
 }