PHP Swift Mailer设置 [英] PHP Swift Mailer Setup

查看:114
本文介绍了PHP Swift Mailer设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将swift邮件程序实现到我的网站,以便我可以向注册用户发送密码恢复电子邮件。我正在使用dreamweaver。我做了什么:

I'm trying to implement swift mailer into my website so I can send password recovery emails to registered users. I'm using dreamweaver. What I have done:

1) Downloaded Swift-4.2.2.tar
2) Extracted it
3) Uploaded to my host in /Domain/classes/lib
4) Included it in Recovery.php

这是我的文件结构

Main Folder
     |classes
          |Swift
     |Private
          |Recovery.php

这里是 Recovery.php

require_once '../classes/lib/swift_required.php';
// Create the Transport
$email_to = $_POST["email"];
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
  ->setUsername('Username')
  ->setPassword('Password')
  ;

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance()

  // Give the message a subject
  ->setSubject('Password Recovery')

  // Set the From address with an associative array
  ->setFrom(array('Username@domain.com' => 'Username'))

  // Set the To addresses with an associative array
  ->setTo($email_to)

  // Give it a body
  ->setBody('Below is your temporary password. Please make sure to login in immediately and change it to a password of your choice.\n'.$password);

// Send the message
$result = $mailer->send($message);

但是这不包括库,因为如果我做 Swift_SmtpTransport :: 然后,dreamweaver应该弹出一个智能感知的东西,给我方法或变量的选项,这意味着它可以看到类和它的所有成员项。但是,由于它没有弹出选项,我得到的感觉,它看不到什么swift类是。当我尝试运行它时,控制台网络选项卡表示它在等待一段时间后才返回一个 500内部服务器错误。所以它不是正确地包括图书馆。任何想法我在做错什么?

But this is not including the libraries because if i do Swift_SmtpTransport:: then dreamweaver should popup an intellisense thing that gives me options of methods or variables, meaning it can see the class and all of it's member items. But since it doesn't popup the options, i get the feeling it cannot see what swift class is. And when I tried to run it, the console network tab said it was pending for a while before it returned a 500 Internal Server Error. So it's not including the libraries properly. Any idea what I'm doing wrong?

编辑:
错误报告输出:

Error reporting output:

Warning: require(/*/*/*/Main Folder/classes/lib/classes/Swift.php): failed to open stream: No such file or directory in /*/*/*/Main Folder/classes/lib/swift_required.php on line 22 
Fatal error: require(): Failed opening required '/*/*/*/Main Folder/classes/lib/classes/Swift.php' (include_path='.:/usr/local/lib/php') in /*/*/*/Main Folder/classes/lib/swift_required.php on line 22


推荐答案

打开swift_required.php文件。在第22行有一个require()。调整它的路径以匹配lib / classes / Swift.php

Open swift_required.php file. There's a require() on line 22. Adjust it's path to match lib/classes/Swift.php

这篇关于PHP Swift Mailer设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆