Avatar of Eduardo Fuerte
Eduardo Fuerte
Flag 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
LaravelPHP

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Stanyon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Favor

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.
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

Eduardo Fuerte

ASKER
Chris

Thank you for the reply!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Chris Stanyon

No worries Eduardo