Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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
swiftmailer未发送和页面未加载php_Php_Html_Swiftmailer - Fatal编程技术网

swiftmailer未发送和页面未加载php

swiftmailer未发送和页面未加载php,php,html,swiftmailer,Php,Html,Swiftmailer,我正在尝试使用swiftmail库发送最简单的php电子邮件,但我无法让它做任何事情。我看过很多人的例子,但仍然有些地方不太对劲。这是我的测试页面,不会发送。我使用的是swiftmailer版本4.1.2 <!DOCTYPE html> <html> <h2>Hello</h2> <?php require_once ("lib/swift_required.php"); $transport = Swift_SmtpTranspor

我正在尝试使用swiftmail库发送最简单的php电子邮件,但我无法让它做任何事情。我看过很多人的例子,但仍然有些地方不太对劲。这是我的测试页面,不会发送。我使用的是swiftmailer版本4.1.2

<!DOCTYPE html>
<html>
<h2>Hello</h2>

<?php


require_once ("lib/swift_required.php");

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


$message = Swift_Message::newInstance()

->setSubject('TEST EMAIL')
->SetFrom(array('email@server.com' => 'my name'))
->setTo(array('email@server.com' => 'me'))
->setBody('TEST MESSAGE USING SWIFTMAILER')
;

$mailer = Swift_Mailer::newInstance($transport);    
$result = $mailer->send($message);
?>
<h3>TEST PAGE</h3>
</html>

你好
测试页

是否有任何错误消息?在SMTP服务器上有没有建立联系的迹象?没有,我希望我有任何东西,但我不能得到任何消息好的,关于
error\u log($result)呢
(或者
echo$result;
如果您想在测试页面上输出它)?该变量包含成功发送的数量,因此1表示成功,0表示失败。此外,例如,使用SMTP服务器发送电子邮件是否在电子邮件客户端中有效?我可以通过SMTP使用php mail发送电子邮件,但swift mailer不能。我会用错误日志试试你的建议