首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHPMailer v6入门

PHPMailer v6入门
EN

Stack Overflow用户
提问于 2017-09-17 18:12:47
回答 1查看 686关注 0票数 0

我是PHPMailer的初学者,因此我想知道我想从PHPMailer文件夹中包含哪个文件。

简单守则:

代码语言:javascript
复制
//Import PHPMailer classes into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);
try {
    //Server settings
    $mail->SMTPDebug = 2;                                 // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'user@example.com';                 // SMTP username
    $mail->Password = 'secret';                           // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
    $mail->addAddress('ellen@example.com');               // Name is optional
    $mail->addReplyTo('info@example.com', 'Information');
    $mail->addCC('cc@example.com');
    $mail->addBCC('bcc@example.com');

    //Attachments
    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    //Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} 

use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;require 'vendor/autoload.php';线。但是在autoload.php文件夹中没有文件夹调用供应商,也没有任何PHPMailer文件。

据网站报道,他们说链接

至少您需要src/PHPMailer.php。如果使用SMTP,则需要src/SMTP.php,如果使用的是POP-在SMTP之前,则需要src/POP3.php。

因此,我删除了使用两行,并添加了三个要求行,即PHPMailer.php、SMTP.php和Exception.php。但它也不起作用。

如何从这个PHPMailer开始。

EN

回答 1

Stack Overflow用户

发布于 2021-03-15 19:21:07

您必须通过这个链接安装composer,单击Composer-setup.exe并运行它。安装之后,您将获得json文件的剪切/复制,并将其粘贴到根目录中,然后转到命令提示符并编写这一行。

作曲家安装

当它完成时,您将得到供应商文件夹,其中将有autoload.php,复制该文件,并粘贴到目录或文件夹中,您的发送邮件文件。如果您想要更多的示例,请单击此链接,有关编写器的更多信息,请阅读此页面

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46267347

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档