Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...