1

我在我的虚拟机上使用 ubuntu。我想使用 catchmail 发送电子邮件,如下所述:http: //berk.es/2011/05/29/mailcatcher-for-drupal-and-other-php-applications-the-simple-version/

我正在尝试发送这样的电子邮件:

//Mailer class:
class Mailer extends PHPMailer
{
public $UTF8Encode = false;
public function __construct($param = null)
{   
    parent::__construct($param);
    $this->Mailer = 'sendmail';
    $this->Sendmail = 'smtp://localhost:1025';
    $this->From   = 'xxxx@xxxx.com';
    $this->FromName = 'Support';
    $this->WordWrap = 50;
    $this->CharSet = 'UTF-8';
}
}

....etc....

和:

//Sending emails

$mail = new Mailer();
$mail->Body = "xxxx";
$mail->Subject = "xxx";
$mail->From = 'xxxx@xxxx.org';
$mail->FromName = 'Support';
$mail->WordWrap = 50;
$mail->AddAddress(xxxx@xxxx.com);

我得到了错误:

Could not execute: smtp://localhost:1025
4

1 回答 1

1
$this->Mailer = 'sendmail';
$this->Sendmail = 'smtp://localhost:1025';

问题在于您告诉 PHPMailer 使用名为sendmail而不是使用 smtp 的命令行程序。PHPMailer 尝试执行以下操作:

exec("smtp://localhost:1025 --args-and-stuff");

正如你所知道的那样,这是行不通的。

要告诉 PHPMailer 使用 smtp,您需要执行以下操作:

$this->Mailer = 'smtp';
$this->Host = 'localhost';
$this->Port = 1025;

如果您的 SMTP 服务器需要身份验证,您可以执行以下操作:

$mail->SMTPAuth = true;
$mail->Username = "yourname@yourdomain";
$mail->Password = "yourpassword";
于 2012-10-26T13:00:47.147 回答