How to setup xampp sedmail with yii2?

Hello,

I would like to know how to send emails from the advance yii2 app(password reset) from the local host to a remote email address please using xampp?

There is server called sendmail.exe which I have setup correctly in xampp but how to get it to work with yii2 please?

Thank you,

Ben

I never got sendmail to work for me, so I’d recommend signing up for a free service instead - sendgrid or mailgun are both good.

When you have XAMPP installed then you should have a local mailserver for your needs.

Its called "Mercury Mail".

So google for "XAMPP Mercury Mail configuration" and you will find a lot of tutorials how to configure…

Regards

Thanks!

Very helpful:-)

Ben

MetaCrawler,

I have followed the steps you gave and it worked, I was quiet amazed by the setup of Mercury, not something you start without knowing what you do. But now I have manage to send emails from Mercury to my gmail account, this connection is working, my next step is…how to connect Mercury to YII2 please?

In the main local you have this:




<?php

return [

    'components' => [

        'db' => [

            'class' => 'yii\db\Connection',

            'dsn' => 'mysql:host=localhost;dbname=forum',

            'username' => 'root',

            'password' => '',

            'charset' => 'utf8',

        ],

        'mailer' => [

            'class' => 'yii\swiftmailer\Mailer',

            'viewPath' => '@common/mail',

            // send all mails to a file by default. You have to set

            // 'useFileTransport' to false and configure a transport

            // for the mailer to send real emails.

            'useFileTransport' => true,

        ],

    ],

];



Or will it work straight out of the box?

Any idea please?

Thank you,

Ben

I use this in components:




        'mailer' => [

            'class' => 'yii\swiftmailer\Mailer',

            // send all mails to a file by default. You have to set

            // 'useFileTransport' to false and configure a transport

            // for the mailer to send real emails.

            'useFileTransport' => false,

            // actual email configuration

            'transport' => [

                'class'    => 'Swift_SmtpTransport',

                'host'     => 'localhost',

                //'username' => '',

                //'password' => '',

                //'port'     => '587',

                //'encryption' => 'tls',

            ],

        ],



I have no relay to a external mail-server like you have.

So I’m not sure if you have to make more settings.

(But actually above config should be enough)

Just for info:

You actually don’t need a relay to external mail (gmail) in development environment.

Cou can create local email addresses in mercury like for example:

admin@localhost.de

webmaster@localhost.de

support@localhost.de

etc etc etc

Then you can setup for example Thunderbird to this mailboxes and have a complete local-mail-system which does not require internet access / external mailbox… ;)

Thank you for the reply.

I think what I will do is simply upload it to a website as I do find it a bit complicated.

I tried to add the code you gave me but received an error about error in token.

No worry I will just upload it on a domain:-)

Thanks again!

Ben