如何使用 Swiftmailer 和 Yii 从本地主机发送电子邮件?

How do I send an email from the localhost with Swiftmailer and Yii?

当我尝试发送邮件时,我从我的邮件服务器收到此错误消息:

Swift_TransportException Expected response code 250 but got code "501", with message "501 5.5.2 <[::1]>: Helo command rejected: invalid ip address"

在调试栏中,我看到 SERVER_ADDR 设置为 ::1,但我找不到更改它的方法。我在 hosts 中注释了 ::1 值,留下 127.0.0.1 并重新启动了 Apache,但它没有帮助。

绕过 Stack Overflow 错误的时髦文字 https://meta.whosebug.com/questions/289410/bug-cannot-submit-question-with-answer

3 wolf moon retro jean shorts chambray sustainable roof party. Shoreditch vegan artisan Helvetica. Tattooed Codeply Echo Park Godard kogi, next level irony ennui twee squid fap selvage. Meggings flannel Brooklyn literally small batch, mumblecore PBR try-hard kale chips. Brooklyn vinyl lumbersexual bicycle rights, viral fap cronut leggings squid chillwave pickled gentrify mustache. 3 wolf moon hashtag church-key Odd Future. Austin messenger bag normcore, Helvetica Williamsburg sartorial tote bag distillery Portland before they sold out gastropub taxidermy Vice.

基于Swiftmailer SMTP transport rejecting local IP address

        'transport' => [
          'class' => 'Swift_SmtpTransport',
          ...
          'encryption' => 'tls',
          'localDomain' => '[127.0.0.1]',
        ],

http://www.yiiframework.com/doc-2.0/yii-swiftmailer-mailer.html(但 localDomain 没有记录!)