Amirilidan78
4 سال پیش توسط Amirilidan78 مطرح شد
8 پاسخ

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

سلام
من میخوام با استفاده از جیمیل خودم با پروژه ای که ساختم با لاراول 7 ایمیل ازسال کنم ولی خطا میده خیلی از سایت ها رو هم گشتم برای مشکل همهشون هم امتحان کردم ,
Error

Swift_TransportException
Failed to authenticate on SMTP server with username "ltemoney.academy@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials u20sm2132177wmc.42 - gsmtp ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials u20sm2132177wmc.42 - gsmtp ". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials u20sm2132177wmc.42 - gsmtp ". 

mail.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Mailer
    |--------------------------------------------------------------------------
    |
    | This option controls the default mailer that is used to send any email
    | messages sent by your application. Alternative mailers may be setup
    | and used as needed; however, this mailer will be used by default.
    |
    */

    'default' => env('MAIL_MAILER', 'smtp'),

    /*
    |--------------------------------------------------------------------------
    | Mailer Configurations
    |--------------------------------------------------------------------------
    |
    | Here you may configure all of the mailers used by your application plus
    | their respective settings. Several examples have been configured for
    | you and you are free to add your own as your application requires.
    |
    | Laravel supports a variety of mail "transport" drivers to be used while
    | sending an e-mail. You will specify which one you are using for your
    | mailers below. You are free to add additional mailers as required.
    |
    | Supported: "smtp", "sendmail", "mailgun", "ses",
    |            "postmark", "log", "array"
    |
    */

    'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

        'ses' => [
            'transport' => 'ses',
        ],

        'mailgun' => [
            'transport' => 'mailgun',
        ],

        'postmark' => [
            'transport' => 'postmark',
        ],

        'sendmail' => [
            'transport' => 'sendmail',
            'path' => '/usr/sbin/sendmail -bs',
        ],

        'log' => [
            'transport' => 'log',
            'channel' => env('MAIL_LOG_CHANNEL'),
        ],

        'array' => [
            'transport' => 'array',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Global "From" Address
    |--------------------------------------------------------------------------
    |
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    |
    */

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    |
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    |
    */

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

فراخوانی تابع mail

Mail::to("Amirilidan78@gmail.com")->send(new \App\Mail\UserRegistered('Amir' , 'fa'));

UserRegistered.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class UserRegistered extends Mailable
{
    use Queueable, SerializesModels;

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

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->markdown('emails.user-registered',[
            'name' => $this->name ,
            'lang' => $this->lang ,
        ]);
    }
}

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
MAIL_USERNAME=ltemoney.academy@gmail.com
MAIL_PASSWORD='Amir.23334152'
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="Lte Money"

*در جیمیل هم قسمت less secure app access رو فعال کردم


ثبت پرسش جدید
علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 4 سال پیش مطرح شد
0

این مشکل،‌ مشکل شبکه هست

Connection could not be established with host smtp.google.com

با وی‌پی‌ان هم امتحان کن..

اگر نشد، تنظیمات زیر رو هم چک کن:

MAIL_PORT=465
MAIL_ENCRYPTION=ssl

حسین شیری نژاد
تخصص : programmer
@hosseinshirinegad98 4 سال پیش مطرح شد
0

مقدار MAIL_HOST رو درست وارد نکردید.

MAIL_HOST=smtp.gmail.com

علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 4 سال پیش مطرح شد
0

داخل فایل ENV احتیاجی به استفاده از سینگل یا دابل کوتیشن نیست.
به شکل زیر امتحان کن:

MAIL_PASSWORD=Amir.23334152

اگر هم Verification از نوع ۲ مرحله ای فعاله، غیر فعال کن و مجددا امتحان کن


Amirilidan78
تخصص : برنامه نویس وب
@Amirilidan78 4 سال پیش مطرح شد
0

سلام ممنون از کمکتون , @ali.bayat @hosseinshirinegad98
با ادیت .env یه ارور دیگ داد

MAIL_DRIVER=smtp
MAIL_HOST=smtp.google.com
MAIL_PORT=587
MAIL_ENCRYPTION=TLS

MAIL_USERNAME=ltemoney.academy@gmail.com
MAIL_PASSWORD=Amir.23334152
MAIL_FROM_ADDRESS=ltemoney.academy@gmail.com
MAIL_FROM_NAME=ltemoney

Error

Swift_TransportException
Connection could not be established with host smtp.google.com :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.
http://127.0.0.1:8000/test 

علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 4 سال پیش مطرح شد
0

این مشکل،‌ مشکل شبکه هست

Connection could not be established with host smtp.google.com

با وی‌پی‌ان هم امتحان کن..

اگر نشد، تنظیمات زیر رو هم چک کن:

MAIL_PORT=465
MAIL_ENCRYPTION=ssl

حسین شیری نژاد
تخصص : programmer
@hosseinshirinegad98 4 سال پیش مطرح شد
0

پورت 2525 رو هم تست کن.


حسین شیری نژاد
تخصص : programmer
@hosseinshirinegad98 4 سال پیش مطرح شد
0

بیشتر این مشکلات میتونه از سرور جی میل باشه و هست. با ********* هم تست کن


Amirilidan78
تخصص : برنامه نویس وب
@Amirilidan78 4 سال پیش مطرح شد
1

@hosseinshirinegad98
@ali.bayat

MAIL_DRIVER = sendmail
'port' => 465,
'encryption' => 'ssl',

درست شد , ممنون


sora
@sh93.rahimi94 3 سال پیش مطرح شد
0

هم دقیقا همین مشکل رو دارم ، لاراول 8


MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_ENCRYPTION=ssl
MAIL_PORT=465

این مشکل رو چه طور حل کردین ؟
بجای smtp، sendmail هم گذاشتم ولی تغییری نکرد
@Amirilidan78


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام