Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过swiftmailer在本地主机中发送邮件_Php_Email_Swiftmailer - Fatal编程技术网

Php 如何通过swiftmailer在本地主机中发送邮件

Php 如何通过swiftmailer在本地主机中发送邮件,php,email,swiftmailer,Php,Email,Swiftmailer,大家好,每个人都是通过php发送邮件的新手,我尝试过使用php函数mail()发送邮件,但似乎不再有效,现在我尝试通过swift mailer发送邮件,但它也不起作用。有人能帮我吗?我尝试过在web上找到一些教程,但结果仍然一样,这是我的代码 require_once 'vendor/autoload.php'; $subject="Testing Mail"; $body="<h2>This is the body</h2>&qu

大家好,每个人都是通过php发送邮件的新手,我尝试过使用php函数mail()发送邮件,但似乎不再有效,现在我尝试通过swift mailer发送邮件,但它也不起作用。有人能帮我吗?我尝试过在web上找到一些教程,但结果仍然一样,这是我的代码

    require_once 'vendor/autoload.php';

$subject="Testing Mail";
$body="<h2>This is the body</h2>";
$to="abouleromaric@gmail.com";  //this is the to email address

// require_once 'swiftmailer/swift_required.php';
// Create the mail transport configuration

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername('abou')->setPassword('abou');
//$transport = Swift_MailTransport::newInstance();
$message = Swift_Message::newInstance()
->setSubject($subject)
->setFrom(array('aboulegbayanga@gmail.com'))
->setTo(array($to))
->setBody($body,'text/html');

//send the message 
$mailer = Swift_Mailer::newInstance($transport);         
$result=$mailer->send($message);
require_once'vendor/autoload.php';
$subject=“测试邮件”;
$body=“这是主体”;
$to=”abouleromaric@gmail.com";  //这是收件人的电子邮件地址
//require_once“swiftmailer/swift_required.php”;
//创建邮件传输配置
$transport=Swift\u SmtpTransport::newInstance('smtp.gmail.com',465,'ssl')->setUsername('abou')->setPassword('abou');
//$transport=Swift_MailTransport::newInstance();
$message=Swift\u message::newInstance()
->setSubject($subject)
->setFrom(数组('aboulegbayanga@gmail.com'))
->setTo(数组($to))
->setBody($body,'text/html');
//发送消息
$mailer=Swift\u mailer::newInstance($transport);
$result=$mailer->send($message);
我从中得到的结果是

致命错误:未捕获错误:调用未定义的方法 中的Swift\u SmtpTransport::newInstance() C:\xampp\htdocs\maili\index.php:12堆栈跟踪:#0{main}已抛出 第12行的C:\xampp\htdocs\maili\index.php


a) 斯威夫特是通过作曲家载入的吗?b) require_once“swiftmailer/swift_required.php”;被注释掉了。也许不应该是?是的,在这里回答: