登录 | 注册 | FAQ
Anonymous

Envio de email com cópia

+ 发表回复

2 篇帖子 分页: 1 / 1


Envio de email com cópia

alefhs » 周五 3月 20, 2015 11:53 am

Bom dia, sou novo na área.
Estou trabalhando em um sistema de chamados, só que peguei ele em andamento e estou meio perdido.
Preciso que o sistema envie um alerta quando o usuário abrir um chamado. Quando o usuário abri o chamado vai uma mensagem pro usuário, mais pra min não está chegando. Já tentei de tudo, se alguém poder me ajudar.
Segue abaixo os arquivos utilizados:

*************UserMailerInterface.php***********************
<?php
namespace Care\Mailers;

use Care\User;

interface UserMailerInterface
{
/**
* e-mail aos usuários
* @param User $user
* @return mixed
*/
public function welcome(User $user);

public function TicketOpened(User $user);

}

*************User.php***********************

<?php
namespace Care\Mailers\Swift;

use Care\Mailers\UserMailerInterface;
use Care\User;

class UserMailer extends Mailer implements UserMailerInterface
{
/**
* Send welcome email to new registered users
* @param User $user
* @return mixed|void
*/
public function welcome(User $user)
{
$view = 'emails.welcome';
$subject = 'Bem-vindo ao Sistema de Chamados TP Tech';
$data = [
'name' => $user->name
];

return $this->sendTo($user->email, $subject, $view, $data);
}

public function TicketOpened(User $user)
{
$view = 'emails.new-ticket';
$subject = 'Novo chamado foi inaugurado';
$data = [
'name' => $user->name
];

return $this->sendTo($user->email, $subject, $view, $data);
}
}



*************Mailer.php*********************

<?php
namespace Care\Mailers\Swift;

use Mail;

abstract class Mailer
{
/**
* Core Mailer
* @param $email
* @param $subject
* @param $view
* @param array $data
*/
public function sendTo($email, $subject, $view, $data = [])
{
Mail::queue($view, $data, function ($message) use ($email, $subject) {
$message->to($email)
->subject($subject);
});
}
}



*************TicketsControler.php*********************

<?php
namespace Client;

use Care\Forms\SubmitTicketForm;
use Care\Mailers\UserMailerInterface;
use Care\Repositories\TicketsRepositoryInterface;
use Care\Repositories\AttachmentsRepositoryInterface;
use Care\Repositories\UsersRepositoryInterface;
use Care\Facades\Uploader;
use BaseController;
use Illuminate\Support\Facades\Auth;
use View;
use Redirect;
use Input;

class TicketsController extends BaseController
{
protected $ticketForm;
protected $tickets;
protected $users;
protected $attachments;
protected $userMailer;

function __construct(SubmitTicketForm $ticketForm,
TicketsRepositoryInterface $tickets,
AttachmentsRepositoryInterface $attachments,
UserMailerInterface $mailer,
UsersRepositoryInterface $users)
{
$this->ticketForm = $ticketForm;
$this->users = $users;
$this->tickets = $tickets;
$this->attachments = $attachments;
$this->userMailer = $mailer;
}

/**
* Display all tickets
* @return \Illuminate\View\View
*/
public function getIndex()
{
$tickets = $this->tickets->getUserTickets(Auth::user()->id);

return View::make('tickets.index', compact('clients', 'tickets'));
}

/**
* Display resolved tickets
* @return \Illuminate\View\View
*/
public function getResolved()
{
$tickets = $this->tickets->getUserClosedTickets(Auth::user()->id);

return View::make('tickets.index', compact('clients', 'tickets'));
}

/**
* Display resolved tickets
* @return \Illuminate\View\View
*/
public function getOpen()
{
$tickets = $this->tickets->getUserOpenTickets(Auth::user()->id);

return View::make('tickets.index', compact('clients', 'tickets'));
}

/**
* Process submission a new ticket
* @return mixed
*/
public function postTicket()
{
$this->ticketForm->validate(Input::all());

// Handle attachments
if (Input::hasFile('attachment')) {
$attachmendId = Uploader::attach(Input::file('attachment'));
}

$ticket = $this->tickets->getNew([
'title' => Input::get('title'),
'content' => Input::get('content'),
'client' => Auth::user()->id,
'attachment_id' => isset($attachmendId) ? $attachmendId : null,
'status' => 0
]);

$client = $this->users->getById(Auth::user()->id);
$this->userMailer->TicketOpened($client);

$this->tickets->save($ticket);

return Redirect::back()->withMessage('Chamado enviado com sucesso');
}

}
头像

alefhs

  • 帖子: 1
  • 注册: 周五 3月 20, 2015 11:50 am

Re: Envio de email com cópia

XainPro » 周六 3月 28, 2015 11:25 am

are you using phpmailer script ?
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm


+ 发表回复

分页: 1 / 1