🎉 سال نو، مهارت نو، مشاوره رایگان نقشه راه برنامه نویسی (آفر ویژه ثبت نام قبل از افزایش قیمت 🔥)
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ سام انوشه
مشکل MailTrap هنگام ارسال ایمیل و اجرای برنامه
جامعه لاراول ایجاد شده در ۱۸ آذر ۱۴۰۱

سلام و احترام

ببخشید من وقتی که برنامه را اجرا میکنم با این خطل مواجه میشوم:

Connection could not be established with host "smtp.mailtrap.io:587": stream_socket_client(): Unable to connect to smtp.mailtrap.io:587 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

من در اینترنت درباره این مشکل سرچ کردم و در خیلی جاها نوشته شده بود که باید در فایل .env به جای tls از ssl استفاده کنم و ...

ولی همه انها تغییر دادم و حالت‌های مختلف را نیز تست کردم ولی باز هم این مشکل را دارم.

کانفیگ فایل .env :

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=XXXXXXXXXXXXXX
MAIL_PASSWORD=XXXXXXXXXXXXXX
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="XXXXXXXXXX@gmail.com"
MAIL_FROM_NAME="Sam Anoosheh"

فایل web.php : (کلاس‌های لازم ایمپورت شده است)

Route::get('/', function () {
    Mail::to('samanXXXXXX@gmail.com') -> send(new TopicCreated);
});

فایل TopicCreated.php :


namespace App\\Mail;
use Illuminate\\Bus\\Queueable;
use Illuminate\\Contracts\\Queue\\ShouldQueue;
use Illuminate\\Mail\\Mailable;
use Illuminate\\Mail\\Mailables\\Content;
use Illuminate\\Mail\\Mailables\\Envelope;
use Illuminate\\Queue\\SerializesModels;
class TopicCreated extends Mailable
{
    use Queueable, SerializesModels;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }
    /**
     * Get the message envelope.
     *
     * @return \\Illuminate\\Mail\\Mailables\\Envelope
     */
    public function envelope()
    {
        return new Envelope(
            subject: 'Topic Created',
        );
    }
    /**
     * Get the message content definition.
     *
     * @return \\Illuminate\\Mail\\Mailables\\Content
     */
    public function content()
    {
        return new Content(
            view: 'emails.topic-created',
        );
    }
    /**
     * Get the attachments for the message.
     *
     * @return array
     */
    public function attachments()
    {
        return [];
    }
}

ممنون میشوم کمکم کنید.

سلام سام عزیز

کدهایی که میل ترپ بهت میده رو عینا با .env جایگزین کن

اگر دوباره همین مشکل بود به دلیل فیلترینگ و مشکلا اینترنت کشور هست.

بهترین پاسخ
احمدرضا فاطمی کیا ۱۸ آذر ۱۴۰۱، ۱۹:۴۰