我想让用户填写一份联系表格,然后发送到我的电子邮箱.但由于某种原因它不起作用.我只是得到一个没有错误消息的空白页面或任何文本和电子邮件也没有发送.
if (isset($_POST['submit']))
{
include_once('class.phpmailer.php');
$name = strip_tags($_POST['full_name']);
$email = strip_tags ($_POST['email']);
$msg = strip_tags ($_POST['description']);
$subject = "Contact Form from DigitDevs Website";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
//$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "info@example.com"; // SMTP account username example
$mail->Password = "password"; // SMTP …Run Code Online (Sandbox Code Playgroud) 有没有人有一个工作示例如何在Laravel 5中使用PHPMailer?在Laravel 4中,它使用起来很安静,但同样的方法在L5中不起作用.这是我在L4中所做的:
添加于composer.json:
"phpmailer/phpmailer": "dev-master",
Run Code Online (Sandbox Code Playgroud)
在controller我使用它像这样:
$mail = new PHPMailer(true);
try {
$mail->SMTPAuth(...);
$mail->SMTPSecure(...);
$mail->Host(...);
$mail->port(...);
.
.
.
$mail->MsgHTML($body);
$mail->Send();
} catch (phpmailerException $e) {
.
.
} catch (Exception $e) {
.
.
}
Run Code Online (Sandbox Code Playgroud)
但它在L5中不起作用.任何的想法?谢谢!
可能重复:
PhpMailer与Swiftmailer?
我一直使用PHP的内置mail()功能,它一直对我有用,并且完成了我想要的工作.
现在有些人可能会想"为什么要修复一些没有破坏的东西?".
如果有人要求,我对这些问题的答案是:
我之前从未使用过框架,如果它被归类为它们或者它们被称为我不知道的库.
我想开始使用一个并查看文档,两者看起来都很容易使用.
当我在我的网站中实现新功能时,我的网站更多地依赖于发送电子邮件等,这意味着PHP的mail()功能不再适用于工作.
在处理附件,HTML和文本版本等高级内容时,它们会更容易使用; 否则使用PHP的mail()功能将是困难或不可能的.
我从来没有使用过SMTP,我已经调查过了,我可以看到我可以在我的托管包中使用它和SSL.经过大量阅读后,似乎不仅SMTP更可靠,使用更广泛,电子邮件不太可能被标记为垃圾邮件,使用任一框架都可以提高性能,可靠性和安全性,因为它使用SMTP和SSL.
现在我不确定使用SMTP的其他好处是什么,也许有人可以给我更多理由为什么它更好?我希望找到有关SMTP好处的更多信息.
我看了两个文档看了他们都提供的功能,搜索谷歌PHPMailer与SwiftMailer,但没有找到任何说明为什么一个比另一个好.
有没有人有任何经验?
一个人比另一个人有更多的好处吗?
你会说一个比另一个好吗?
我确实读过很多人说PHPMailer是一个死的项目,但那些帖子相对较旧.看看PHPMailer的网站,似乎该项目已经并且已经开发了一段时间了.
感谢您在PHPMailer和/或SwiftMailer上提供的任何功能.希望我能决定一方或另一方,因为此刻我没有理由为什么我会选择一方而不是另一方.
SMTP错误:无法连接到SMTP主机.无法发送消息.
邮件程序错误:SMTP错误:无法连接到SMTP主机.
我似乎找不到让PHPMailer在CentOS下工作的方法.使用XAMPP在Windows下邮件工作正常,但我总是在Linux下遇到此错误.
SMTP服务器是在端口25上侦听的Lotus Domino,CentOS机器根本没有防火墙,奇怪的是即使mail()也不起作用.它什么都不返回(在Windows上返回1).如果我通过CentOS服务器通过telnet发送电子邮件,它可以正常工作,所以我不认为这是一个网络问题.它必须与PHP相关,但我不知道如何.
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "192.168.x.x";
$mail->SMTPAuth = false;
$mail->From = "xxx@xxx.it";
$mail->FromName = "XXX";
$mail->AddAddress("xxx@xxx.it");
$mail->IsHTML(true);
$mail->Subject = "Test";
$mail->Body = "Test";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
Run Code Online (Sandbox Code Playgroud)
只是为了澄清上面的代码适用于XAMPP(Windows).
我在PHPMailer上调试了错误,这里发生错误(class.smtp.php方法Connect()):
$this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // …Run Code Online (Sandbox Code Playgroud) 所以我在尝试使用PHPmailer从我的网站发送邮件时收到此错误.
SMTP错误:以下收件人失败:XXXX
我试着设置$ mail-> SMTPAuth = true; 是假但没有结果.我试图更改邮件帐户的密码,并在sendmailfile.php中更新,但仍然相同.
两天前它按预期工作,现在我不知道为什么会这样.由于没有任何错误代码,我不知道从哪里开始,因为它确实有效..
谁可能知道?
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->ContentType = 'text/html';
$mail->IsSMTP();
$mail->Host = "HOST.COM";
$mail->SMTPAuth = true;
$mail->Username = "MAIL_TO_SEND_FROM";
$mail->Password = "PASSWORD";
$mail->From = "MAIL_TO_SEND_FROM";
$mail->FromName = "NAME";
$mail->AddAddress($safeMail);
$mail->AddReplyTo("no-reply@example.COM", "No-reply");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$sub = "SUBJECT";
mail->Subject = ($sub);
Run Code Online (Sandbox Code Playgroud) 我使用phpmailer发送电子邮件,但我想为我的公司制作一个自定义标题,通过添加包含任何自定义标题的textarea字段,例如使用像这样的标题:
标题 或任何其他标题类型的例子..我怎么能这样做,提前谢谢.
如何在PHPMailer中启用持久性SMTP连接?
我会发送很多电子邮件,所以通过持久连接,我可能会获得性能提升.
我正在尝试使用phpMailer通过电子邮件向用户发送确认消息.我的代码是这样的:
<?php
include("class.phpmailer.php");
include("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server
$mail->Port = 465; // set the port to use
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "sender@gmail.com"; // your SMTP username or your gmail username
$mail->Password = "mypasswrord"; // your SMTP password or your gmail password
$from = "webmaster@example.com"; // Reply to this email
$to="receiver@yahoo.com"; // Recipients email ID
$name="Jersey Name"; // Recipient's …Run Code Online (Sandbox Code Playgroud) 为什么?我可以用PHP发送邮件(),但我无法使用IsSendmail()通过PHPMailer发送
PHPMailer检查is_file每个附件(在addAttachment函数中,在class.phpmailer.php文件中):
if (!@is_file($path)) {
throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,我is_file只能提供完整的本地文件路径,而不是URL:
is_file('C:/wamp/www/myFolder/rocks.png'); //True
is_file('http://localhost/myFolder/rocks.png'); //False :(
Run Code Online (Sandbox Code Playgroud)
所以我无法从远程服务器附加任何文件.
我究竟做错了什么??这可能是许可问题吗?
编辑:
我知道还有其他方法可以检查文件是否存在.
但是is_file在PhpMailer库中,我更喜欢不触摸它,我想知道是否可以使用它的方法使其工作.
谢谢.
phpmailer ×10
php ×8
smtp ×6
email ×2
gmail ×1
header ×1
laravel-5 ×1
performance ×1
return-path ×1
ssl ×1
swiftmailer ×1