dongyan2469 2017-01-18 15:34
浏览 60
已采纳

如何在Windows机器上使用swiftmailer发送电子邮件?

The swiftmailer documentation explains that for sending an email we have to create a Transport, mailer, message and then send it. Now i want to send an email from localhost and how to configure the transport for the windows machine. The dummy code by their documentation is:

$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)->setUsername('your username')->setPassword('your password');

Now what should be the values of arguments so that being on windows i could send the mail from localhost. I 'm using Xampp.Please help me.

  • 写回答

1条回答 默认 最新

  • duanla8800 2017-01-18 15:39
    关注

    If by "sending from localhost" you only mean the script runs on localhost, but you are able to send the email from an external server, then you need an SMTP server you can use (for example the one you use for all your email anyway, whichever server that is) and use your credentials as long credentials in the transport. Nobody can tell you what that is, as we neither now your mail service, nor, obviously, your username and password there.

    However if you do not have an external SMTP server to use, or do not want to use one, you need to run an SMTP server on your local machine. Covering how to set up an SMTP server on a windows machine is way outside the scope of SO. However I would not advise to do this outside of testing scenarios anyway, as mail originating from dynamic IP addresses (which you likely ahve) with no valid reverse DNS or reverse DNS that does not match the hostname (which you likely also have) is not accepted by any sane mails server anyway and considered spam.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵