Symfony SymfMail - 如何发送电子邮件

I want to send an email with symfony symfmail but theres a problem. My code doesn't throw error but it isn't sending anything. What's worse, it doesn't show is my connection with smtp correct or any error. What to do?

Here's my controller method:

 /**
 * @Route("/mail")
 */
public function mail(\Swift_Mailer $mailer){
    $message = (new Swift_Message('Wonderful Subject'))
        ->setFrom(['I SET IT!' => 'John Doe'])
        ->setTo(['I SET IT!', 'I SET IT!' => 'A name'])
        ->setBody('Here is the message itself')
    ;

    $result = $mailer->send($message);
    return new Response(var_dump($result));
}

I don't know. Maybe i just doesn't configure it good or smtp is not configured form my wamp64 in localhost.

Please help with that.

UPDATE:

I get this code when i look into toolbar errors. Is it because i send it form localhost?

Exception occurred while flushing email queue: Connection could not be established with host localhost [No connection could be made because the target machine actively refused it. #10061]

my .env file

    # This file is a "template" of which env vars need to be defined for your application
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=e772aaf55e2eb077062f1d98468e6f59
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=mysql://root:@127.0.0.1:3306/cms
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://MY_MAIL_WITHOUT_AT_CHAR_AND_DOMAIN:MY_PASSWORD@EMAILDOMAIN:SSL_PORT
#MAILER_URL=smtp://localhost:25?encryption=ssl&auth_mode=login&username=&password=
#MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###

UPDATE: Ok i know where's problem i tried send it from console and this is what i got:

19:40:53 ERROR     [app] Exception occurred while flushing email queue: 
Connection could not be established with host localhost [No connection could be made because the target machin
e actively refused it.
 #10061]

You have a problem in your .env configuration!

MAILER_URL=smtp://MY_MAIL_WITHOUT_AT_CHAR_AND_DOMAIN:MY_PASSWORD@EMAILDOMAIN:SSL_PORT

please change it and give your Email Credentials and Configurations so you can send emails with it.

I am not a Windows user, but based on your environment, if you have any mail server, it is configured on your localhost, like your web server. so just find the port its listening.

I didn't do it yet but i see it's problem with sending emails from localhost, because even with mail() function it didn't work but on my server in web it did. Thanks for help.