Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.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发送电子邮件_Php_Email_Smtp_Pear_Rackspace Cloud - Fatal编程技术网

无法使用PHP发送电子邮件

无法使用PHP发送电子邮件,php,email,smtp,pear,rackspace-cloud,Php,Email,Smtp,Pear,Rackspace Cloud,我试着用pear发送电子邮件。这是我的密码 <?php require_once "/usr/share/pear/Mail.php"; require_once "/usr/share/pear/Mail/mime.php"; $to = "Info <info@mydomain.com>"; $subject = "Contact Form - mydomain.com\r\n\r\n"; $host = "smtp.zoho.com"; $username = "no

我试着用pear发送电子邮件。这是我的密码

<?php
require_once "/usr/share/pear/Mail.php";
require_once "/usr/share/pear/Mail/mime.php";

$to = "Info <info@mydomain.com>";
$subject = "Contact Form - mydomain.com\r\n\r\n";

$host = "smtp.zoho.com";
$username = "noreply@mydomain.com";
$password = "abc@123";
$port = "465";

//Sender Details
$sender_name = $_POST['name'];
$from = $_POST['name']." <".$_POST['email'].">";
$sender_phone = $_POST['phone'];

//Create Message
$body = $_POST['message'];
//$body = wordwrap($body, 70, "\r\n");
$body = $body . "\r\n" . "Phone: " .$sender_phone;

if($sender_name != "" && $_POST['email'] != "" && $body != "" && $sender_phone != "")
{
    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject,
      'Reply-To: ' => $from);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));

    $mail = $smtp->send($to, $headers, $body);
    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
    } else {
      header("Location:contact-us.php?mcode=1");
    }
}
else
{
    header("Location:contact-us.php?mcode=2");
}
?>
我正在使用Rackspace cloud和Zoho电子邮件系统

当我这样做的时候:

[root@mydomain /]# find -name Mail.php
./usr/share/pear/Mail.php
这就是为什么我直接将它包含在php文件中

还有当我这么做的时候

[root@mydomain /]# find -name mime.php
./usr/share/pear/Mail/mime.php
因此,我使用了
require\u once”/usr/share/pear/Mail/mime.php“
,但是在一个示例中,我不太确定为什么使用这一行

可能的原因是什么?我如何解决

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';

$mail->Host       = "mail.example.com"; // SMTP server example
$mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "username"; // SMTP account username example
$mail->Password   = "password";        // SMTP account password example

您可以在这里找到关于PHPMailer的更多信息:

我可以看看您的表单html代码吗?php没有从提交中获取post值form@crack页面获取数据,就像我删除
require\u once”/usr/share/pear/Mail.php
require_once”/usr/share/pear/Mail/mime.php
It echoz everything Fine chrome loader旋转几分钟,然后出现这个chrome错误,[有问题的屏幕截图]通常为“/usr/share/pear/Mail.php”这不应该让www数据或apache2用户访问。实际上,您不需要使用这个
require_once”/usr/share/pear/Mail.php”;需要_once“/usr/share/pear/Mail/mime.php”发送电子邮件。您只需要安装postfix(邮件服务器)和邮件功能即可发送电子邮件。如果您想使用stml,那么我建议您使用phpmailer。只需在没有这些必需文件的情况下使用Django—这是您发布的PHP代码抛出错误的第二个问题。显然,您的服务器/安装有问题。这可能值得重新构建并重新部署以获得一个新的记录。但这样做会产生致命错误
PHP致命错误:在第26行的/var/www/html/contact-us-process.PHP中找不到类“Mail”
我有请求,尝试使用phpmailer的life saver库发送电子邮件,别忘了在您的机器上安装postfix,但我在phpmailer
SMTP错误:数据不被接受。
在谷歌搜索了一段时间后,我找不到任何具体的解决方案。请您提供帮助。调试后,我发现这是一个完整的错误
命令失败:553中继不允许的SMTP错误:数据不接受。邮件程序错误:SMTP错误:数据不被接受。
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';

$mail->Host       = "mail.example.com"; // SMTP server example
$mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "username"; // SMTP account username example
$mail->Password   = "password";        // SMTP account password example