Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

Could you point a Laravel library to send an email after an action?

Hi Experts


Could you point a Laravel library to send an email after an action?

After an user sends an image to be shown at a vitrine it must to be approved/ reproved by the admin and then an email must to be automatically sent to the user relating the result.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Expanding on comment Chris made, start with a relay service like MailGun, for instant delivery.

Then as time permits, go through steps https://www.experts-exchange.com/questions/29165628/Sending-Email-by-getting-email-address-from-database.html provides, if running your own in house MTA is required.
Avatar of Eduardo Fuerte

ASKER

Hi Chris


Really... the site already uses the approach you had pointed...


What I had adpted is:

Controller

use App\Mail\FotoAprovada;
use Mail;

  try {
	$vitrine->save();
	$resultado=new Resultado(false,"","Foto aprovada com sucesso.");
	
   // Email 
	 try {
		Mail::to($vitrine->email)
			->send(new FotoAprovada());
	} catch (\Exception $e){
		print ' - '.$e->getMessage().PHP_EOL;
 }

Open in new window



\app\mail\fotoaprovada\index.blade.php

Email text:

<html>
<head>
<title>Foto Aprovada</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>

</style>
</head>
<body bgcolor="#003366" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td style="text-align:center;">
      <img alt="" src="https://XXXX/vitrines/a2bae276qw86e8q6q8we6q8e668qe68qe6e868qw686e2f3df.jpg"/>
 
    </td>
	</tr>
</table>
</body>
</html>

Open in new window



<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class FotoAprovada extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.fotoaprovada.index')->subject('XXXXXXXX - Foto Aprovada');
    }
}

Open in new window

Chris

Thank you for the reply!
No worries Eduardo