2015-10-15 61 views
1

我用PhpMailer发送邮件,但我想将邮件保存在我的webmail和Outlook中的“已发送”文件夹中。我有一个脚本,但它无法打开(imap_open)该文件。“imap无法打开” - 我已发送文件夹的路径是什么?

什么是正确的路径?

下面是脚本:在服务器上

<?php 
require($_SERVER['DOCUMENT_ROOT'].'/admin/PHPMailer/class.phpmailer.php'); 
require($_SERVER['DOCUMENT_ROOT'].'/adminPHPMailer/PHPMailerAutoload.php'); 

class Mailer extends PHPMailer { 

    public function copyToFolder($folderPath = null) { 
     $message = $this->MIMEHeader . $this->MIMEBody; 
     $path = "/." . (isset($folderPath) && !is_null($folderPath) ? ".".$folderPath : ""); // Location to save the email 
     //$imapStream = imap_open("{" . $this->Host . "}" . $path , $this->Username, $this->Password); 
     $imapStream = imap_open("{" . $this->Host . "}" . $path ,"[email protected]", "password"); 

     imap_append($imapStream, "{" . $this->Host . "}" . $path, $message); 
     imap_close($imapStream); 
    } 
} 


$mail = new Mailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth = true;  
$mail->Host  = "localhost"; // sets the SMTP server 
$mail->Port  = 26;     // set the SMTP port 
$mail->Username = "[email protected]"; // SMTP account username 
$mail->Password = "password";  // SMTP account password 
$mail->From = "[email protected]"; 
$mail->FromName = "Don Joe";    
$mail->AddAddress("[email protected]"); 
$mail->WordWrap = 50;        
$mail->IsHTML(true);         
$mail->Subject = "tárgy"; 
$mail->Body = $message; 
$mail->AltBody = $message; 


if(!$mail->Send()) 
{ 

    echo "Message was not sent <p>"; 
    echo "Mailer Error: " . $mail->ErrorInfo; 

    exit; 
}else{ 
    $mail->copyToFolder(); // Will save into inbox 
    $mail->copyToFolder("Sent"); // Will save into Sent folder 
} 
?> 

我的文件结构调查:

0:/mail/mydomain.com/address/.Sent 

我的网站:

0:/public_html/mydomain.com (this is root of my website under my domain) 

我的Web客户端配置:

Username: [email protected] 
Password : password 
Incoming server: mail.mydomain.com 
IMAP port: 143 
POP3 port: 110 
Outgoing server: mail.mydomain.com 
SMTP port: 26 

错误消息:

警告:imap_open()[function.imap开]:无法打开流

警告:imap_append()预计参数1是资源,在布尔给出

警告:imap_close()预计参数1是资源,布尔在

回答

0

给出则可以将您的邮箱(完整的文件夹名称)的所有文件夹的名称,大多数邮件服务器的名称为对于发送的文件夹INBOX.Sent或INBOX.SentItems等您应该提供完整的名称。

相关问题