mercredi 17 octobre 2018

How to set up a smtp connection on a domain email in laravel

I have a domain: www.mydomain.ro and i created an email like this: office@mydomain.ro

I'm trying to send emails from my laravel application(laravel 5.7) and i did this configurations:

In .env file:

    MAIL_DRIVER=smtp
    MAIL_HOST=office@my-domain.ro
    MAIL_PORT=26
    MAIL_USERNAME=office@my-domain.ro
    MAIL_PASSWORD=mypassword
    MAIL_ENCRYPTION=null

And in config/mail.php:

<?php

return [

    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'mail.my-domain.ro '),

    'port' => env('MAIL_PORT', 26),

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'office@muy-domain.ro'),
        'name' => env('MAIL_FROM_NAME', 'Office my-domain'),
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('office@my-domain.ro'),

    'password' => env('mypassword'),

    'sendmail' => '/usr/sbin/sendmail -bs',

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

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

];

In Controller i'm doing this:

$data = array(
    'name' => 'Ioan Andrei',
    'body' => 'Test Email'
);


Mail::send('emails.demandreceived',$data,function ($message){
    $message->from('office@my-domain.ro','TEST');
    $message->to('ioan.andrei97@gmail.com');
    $message->subject('Test email');

I get this error:

Connection could not be established with host office@msipremiumcars.ro [php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known #0]

What am i doing wrong?It's not working beacuse i'm trying to send them from my local server?

Can i use mailgun for example to send the email and still have the email send from office@mydomain.ro?

I tried to restart my local server after configs.

Laravel version: 5.7



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire