🔥 با کمک هوش مصنوعی در کمتر از 6 ماه فول‌استک شوید ...
۰ ثانیه
۰ دقیقه
۰ ساعت
۷ اورنگ فرج
خطا در هنگام ارسال ایمیل
جامعه پی اچ پی ایجاد شده در ۲۲ خرداد ۱۴۰۲

سلام این خطا برای من میاد موقع که میخوام ایمیل ارسال کنم

0401-Screenshot 2023-06-12 165224.png

بعدش من دستور php artisan make:mail میزنم محتوای با خود فیلم فرق میکنه به شکل زیر هست

19ef-code.png

اینم کد‌های مربوط به paymentController :

c3ed-photo.jpg

سلام امیر عزیز

از سرویس 403 استفاده کن تا ارتباط برقرار شه.

آقای افرنگ بخاری ۲۲ خرداد ۱۴۰۲، ۱۴:۰۰

استفاده میکنم الان محتوای mail که فرق کرده تاثیر نداره؟

اورنگ فرج ۲۲ خرداد ۱۴۰۲، ۱۴:۰۴

خطایی که دریافت کردید در برقراری ارتباط هست.

آقای افرنگ بخاری ۲۳ خرداد ۱۴۰۲، ۱۰:۰۱

خوب اون مشکلم هست الان یه مشکل جدی‌تر از اون اینه تو ورژن جدید لاراول محتوای mail با قبلی فرق کرده الان به چه صورت همین مورد اموزش تو نسخه جدید پیاده سازی کنم؟؟؟؟

اورنگ فرج ۲۳ خرداد ۱۴۰۲، ۱۱:۱۲

پیاده سازیتون مشکلی نداره(فقط آرگومان هایی که به کلاس ارسال ایمیل دادید رو در کانستروک تعریف کنید و مام ویو مربوطه هم درست وارد کنید)

مشکل در ارتباط هست که باید تغییر آیپی بدید

آقای افرنگ بخاری ۲۳ خرداد ۱۴۰۲، ۲۰:۱۲

این کد قدیمی هستش همین میخوام بیارم تو محتوای mail جدید که بالا فرستادم به چه صورتی میشه ؟؟

class SendOrderImages extends Mailable
{
    use Queueable, SerializesModels;
    /**
     * Create a new message instance.
     */
    public function __construct(private array $images,private User $user)
    {
        //
    }
    /**
     * Build the Message
     * 
     * @return $this
     */
    public function build()
    {
        $email = $this->view('mail.sendOrderedImages')->with([
            'user' => $this->user,
        ]);
        foreach ($this->images as $filePath) {
            $email->attach(storage_path('app/local_storage/' . $filePath));
        }
        return $email;
    }
}

و سوال دوم این خطا برای چی هست ایا چون تو لوکال هستم این خطا رخ داده و لازمه فرم‌ها با استفاده از پروتکل https فرستاده شود ؟

https://s8.uupload.ir/files/screenshot_2023-06-14_182251_3nv2.png

چون نشد پیوست کنم مجبور شدم جای دیگری آپلود کنم!

اورنگ فرج ۲۴ خرداد ۱۴۰۲، ۱۵:۱۳

در فرمت جدید کلاس ایمیل لاراول به این صورت باید کدنویسی کنید:


namespace App\\Mail;
use App\\Models\\User;
use Illuminate\\Bus\\Queueable;
use Illuminate\\Contracts\\Queue\\ShouldQueue;
use Illuminate\\Mail\\Mailable;
use Illuminate\\Mail\\Mailables\\Attachment;
use Illuminate\\Mail\\Mailables\\Content;
use Illuminate\\Mail\\Mailables\\Envelope;
use Illuminate\\Queue\\SerializesModels;
class SendOrderedImages extends Mailable
{
    use Queueable, SerializesModels;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(private array $images, private User $user)
    {
        //
    }
    /**
     * Get the message envelope.
     *
     * @return \\Illuminate\\Mail\\Mailables\\Envelope
     */
    public function envelope()
    {
        return new Envelope(
            subject: 'Send Ordered Images',
        );
    }
    /**
     * Get the message content definition.
     *
     * @return \\Illuminate\\Mail\\Mailables\\Content
     */
    public function content()
    {
        return new Content(
            view: 'mail.sendOrderedImages',
            with: [
                'user' => $this->user,
            ],
        );
    }
    /**
     * Get the attachments for the message.
     *
     * @return array
     */
    public function attachments()  {  
        $email = [];
        foreach ($this->images as $filePath){
            $email[] = Attachment::fromPath(storage_path('app/local_storage/' . $filePath));
        }
        return $email;
    }
}
رعنا اعتماد ۰۱ تیر ۱۴۰۲، ۰۲:۰۳