Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

php - Laravel mail notification are taking wrong path for default markdown view file in docker

I am deploying my application using docker and kubernetes. Laravel version is 5.8.

I am facing wrong path issue while sending mail notification using horizon (worker docker).

While normal Mailables are working just fine.

For example: VerifyRegistration mailable is working fine

<?php

namespace AppMail;

use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
use IlluminateContractsQueueShouldQueue;

class VerifyRegistration extends Mailable
{
    use Queueable, SerializesModels;

    protected $username;
    protected $url;
    protected $validityHours;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($username, $url, $validityHours)
    {
        $this->username = $username;
        $this->url = $url;
        $this->validityHours = $validityHours;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->markdown('emails.verify_registeration')->with([
            'username' => $this->username,
            'url' => $this->url,
            'validityHours' => $this->validityHours,
        ]);
    }
}

but EmailOTPNotification which is a notification class, is not working. Error screenshot is attached below.

<?php

namespace AppNotifications;

use IlluminateBusQueueable;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;

class EmailOTPNotification extends Notification implements ShouldQueue
{
    use Queueable;
    protected $message;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return IlluminateNotificationsMessagesMailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->subject('Example.com OTP')
                    ->line($this->message)
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

Horizon Error:

enter image description here

The error says it does not find view file at location /var/www/html/buy_sell/****

But as per the worker's docker file my app resides at /var/www/ location only (see the worker's Dockerfile) while, /var/www/html/buy_sell/ is the project location in my machine.

Below is the Dockerfile of my worker:

FROM php:7.3-cli

RUN docker-php-ext-install -j$(nproc) pdo_mysql mbstring pcntl bcmath

RUN apt-get update && apt-get install -y supervisor && apt-get clean

# Set working directory
WORKDIR /var/www

COPY . /var/www

COPY ./docker_files/worker/conf/supervisord.conf /etc/supervisor/supervisord.conf
COPY ./docker_files/worker/conf/horizon.conf /etc/supervisor/conf.d/horizon.conf
COPY ./docker_files/worker/conf/laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

Please help me in this regards.

question from:https://stackoverflow.com/questions/65917272/laravel-mail-notification-are-taking-wrong-path-for-default-markdown-view-file-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...