How to get smtp username and password for laravel mail

To get the SMTP username and password for Laravel mail, you'll need to configure your email service provider. Here are the steps:

1. Choose an email service provider: Laravel supports several email service providers, including:

2. Create an account with your chosen email service provider: Sign up for an account with your chosen email service provider. This will give you access to your account dashboard and settings.

3. Get your SMTP credentials: In your email service provider's dashboard, look for the SMTP settings or credentials section. This is where you'll find your SMTP username and password.

4. Configure your Laravel project: In your Laravel project, open the config/mail.php file and update the smtp section with your email service provider's credentials.

Here's an example of how to configure Mailgun:

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

Replace your-mailgun-username and your-mailgun-password with your actual Mailgun credentials.

5. Set environment variables: In your .env file, set the following environment variables:

MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=your-mailgun-username
MAIL_PASSWORD=your-mailgun-password

6. Test your email configuration: Run the following command in your terminal to test your email configuration:

php artisan mail:send --queue

This will send a test email using your configured email service provider.

That's it! You should now have your SMTP username and password set up for Laravel mail.