Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cuartas15's avatar

Questions about mass Email with Scheduler

I have 2 specific questions about email in production:

  • Since I'm a total novice on this, I finally got to configure a site on Laravel Forge properly, I can send emails via cron job using the php artisan schedule:run, but I've come to realize this won't work by just using Private Email provided by Namecheap as an email service.

The domain I'm using on my site is stored in Namecheap so I thought using and configuring an email there too would be easy and convenient, I paid for the [email protected], created a bunch of aliases and included them in my application to send emails, and it works, but the email service only allows 500 mails per hour.

I'm not looking to send mass emails as marketing or email lists (for now), what my app is doing is: Use a job to retrieve a list of appointments assigned to the next day in order to send a reminder to the clients, so each email is unique because it has an individual client name/appointment date/time and meeting address. What I've been using to achieve this is Laravel notification, the one that comes with it but slightly modified (I just changed the markdown a little bit).

The amount of appointments per day can go up to hundreds of thousands in the future so I need a service that can do that for me without worrying about email limits and blacklisted ips.

Not to mention I'm using the same notification system for password resets, appointment cancelations, contact and other functions.

So I'm looking for something that can cover these needs, I've been looking mailgun, mailchimp, etc but all of these are oriented on Marketing? and like I said I don't really want that for now but something that can allow me to send massive amounts of mails at once and at the same time individual messages as well? maybe since I know nothing about this I think those services aren't for me but they actually are? that's why I need help about it.

  • This question is more related to Laravel, in production, when I send emails with the scheduler, that email isn't coming with a small image logo but just the alt text, when I inspect it, it's sending something with a localhost route for some reason, this is just for this specific case of sending notifications via jobs, if I for example send a password reset email, the image is showing up just fine, is there something I have to do diferently about it?

This is what my blade template looks like:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.exturllink')])
            <img src='{{ asset('images/sme_logo.png') }}' height='70' alt='{{ config('app.subname') }}'>
        @endcomponent
    @endslot
    {{-- ... --}}
0 likes
17 replies
cuartas15's avatar

Uhhh... I don't think making a preview will be an easy task because I don't really save any email content and my emails are notifications and not just mailables per se? I can show you what I see in my email though.

Password reset: https://i.gyazo.com/f297d5dfd7548b847972d37ebf3da2d5.png

Appointment notification via scheduler: https://i.gyazo.com/6ff4b30fc463734b07d664d96a96fa25.png

Like I said, all my emails are based on MailMessage from the default Laravel notifications boilerplate

Sinnbeck's avatar

Try changing to this (should fix the missing part of the url)

<img src='{{ url('images/sme_logo.png') }}' height='70' alt='{{ config('app.subname') }}'>
cuartas15's avatar

Same result unfortunately. Something has to be happening with a mail being sent via scheduler

Sinnbeck's avatar

You can try rendering it to log just before sending to see what it outputs. Or at least try putting url('images/sme_logo.png') to log.. I see no way the scheduler should be able to change this, as it uses the same config.

cuartas15's avatar

hmm, this is weird, Telescope is not giving me any logs about it, I just added this to the blade template, it works in local but not in production

@php
    \Log::info(url('images/sme_logo.png'));
    \Log::info(asset('images/sme_logo.png'));
@endphp
Sinnbeck's avatar

Try rewriting your config cache

php artisan config:cache
cuartas15's avatar

Nada, I don't think anything wants to work for me in the foreseeable future, perhaps I will have to live with the fact that only single email is coming without logo

Sinnbeck's avatar

Very strange indeed. Sadly I don't have any clever suggestions

Sinnbeck's avatar

One thing. You might want to look into embedding images. Using url will cause the recipient to have accept downloading it. If it's embedded it just loads (and perhaps your issue will be fixed as well)

It will fill a bit more, but if the image is small, it does not matter much

https://laravel.com/docs/6.x/mail#inline-attachments

cuartas15's avatar

Alright, I'm gonna try that out later, for now I configured a mailgun account and I'm going for the most basic setup for now that is using the smtp config instead of the API or the lib you provided, changed my env file, restarted the server and for some reason my app is still sending emails through my old configuration (meaning old domain vs a new domain name that I used for mailgun specifically).

Do I need to clear some cache or something?

Sinnbeck's avatar

Yes always redo your cache when changing config

php artisan config:cache
cuartas15's avatar

Ok so this was actually a mistake from my part, my MAILGUN_DOMAIN and MAILGUN_SECRET were missing in my env file, once I put them with the correct information I finally got emails from the right domain

Snapey's avatar

when urls are generated from events or cron jobs, laravel cannot use the request domain to set the hostname for assets. Instead, it uses the app url from config.

Personally, I use Postmark, and they are highly recommended

cuartas15's avatar

Hmm, that's an issue this is what I have:

APP_URL="/"
APP_EXT_URL=""
APP_EXT_URL_LINK="http://mydomain.com/"

The issue is if I put my url on APP_URL it messes with basically almost everything that is out there in the web page that is made to go back to the root page, that's why I added APP_EXT_URL and APP_EXT_URL_LINK, to not mess with these other functions.

Just to put it into context: I use APP_EXT_URL for the action button of all my emails that are not coming from my scheduler like so:

->action('Publicar Valoración', url(config('app.exturl') . route('review.confirm', $this->token, false)))

If I just use APP_URL the action will have a totally incorrect url, basically pointing to localhost

APP_EXT_URL_LINK is specific for the mail sent via scheduler and I have to use it like this:

->action('Visitar perfil del especialista', url(config('app.exturllink') . 'p/' . $this->module_title))

It is also being used for the href in my message's template logo.

So yeah, I don't know what exactly I am doing wrong but for now I came up with these workarounds to get it working in all these different situations

Snapey's avatar

I always use the route helper in views and never have such issues

cuartas15's avatar

That's an insteresting approach, but I tried that and then I put my site url in APP_URL and yet still the logo isn't showing up, giving me exactly the same html structure when I inspect it

Please or to participate in this conversation.