退出状态代码 1 无法发送电子邮件


Exit status code 1 Unable to send email

我正在尝试使用Codeigniter为我的项目提供的电子邮件类向注册我网站的人发送电子邮件。我收到以下错误消息。

Exit status code: 1
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to sendmail using this method.
$this->email->message('Welcome to '.$this->config->item('company_name').', "'r'n" Thank you for joining the '.$this->config->item('company_name').' team. We have listed your registration details below. Make sure you save this email. To verify this account please click the following link. "'r'n" '.anchor('register/verify/'.$registration_key, 'Click Here To Activate Your Account', '').' "'r'n" Please verfiy your account within 2 hours, otherwise your registration will become invalid and you will have to register again. "'r'n" Your email address: '.$post_email_address.' "'r'n" Your Password: '.$post_password.' "'r'n" Enjoy your stay here at '.$this->config->item('company_name').' "'r'n" The '.$this->config->item('company_name').' Team');

更新:

正在更新我的代码,因为由于某种原因我仍然收到相同的错误,并且我无法弄清楚是什么给了我错误。

../application/configs/site_configs.php
<?php
$config['company_name'] = 'My Test Site';
$config['comapny_email'] = 'owner@testingsite.com';

我还想在这里提到我正在自动加载我的站点配置文件。

$autoload['config'] = array('site_configs');

寄存器控制器

// User was successfully created and the user needs to verify their account.
// Send registered an email informing them how to validate their account.
$this->load->library('email');
$this->email->from($this->config->item('company_email'), $this->config->item('company_name'));
$this->email->to($post_email_address);
$this->email->subject($this->config->item('company_name').' Registration');
//$message = 'Welcome to '. $this->config->item('company_name') ."'r'n";
//$message .= 'Thank you for joining the ' . $this->config->item('company_name') . ' team.';
//$message .= 'We have listed your registration details below. Make sure you save this email.';
//$message .= 'To verify this account please click the following link.'."'r'n";
//$message .= anchor('register/verify/'.$registration_key, 'Click Here To Activate Your Account', '')."'r'n";
//$message .= 'Please verfiy your account within 2 hours, otherwise your registration will become invalid and you will have to register again.'."'r'n";
//$message .= 'Your email address: '.$post_email_address."'r'n";
//$message .= 'Your Password: '.$post_password."'r'n";
//$message .= 'Enjoy your stay here at '.$this->config->item('company_name')."'r'n";
//$message .= 'The '.$this->config->item('company_name').' Team';
$this->email->message('Great registration.' /*$message */);
$this->email->send();
echo $this->email->print_debugger();

还要尝试让你的代码更具可读性。我注意到,您用于消息的巨大字符串充斥着进出动态变量的延续。在进行过程中将字符串链接在一起。

为什么不试试

$message = 'Welcome to '. $this->config->item('company_name') ."'r'n";
$message .= 'Thank you for joining the ' . $this->config->item('company_name') . ' team.';
$message .= 'We have listed your registration details below. Make sure you save this email.';
$message .= 'To verify this account please click the following link.'."'r'n";
$message .= .anchor('register/verify/'.$registration_key, 'Click Here To Activate Your Account', '')."'r'n";
$message .= 'Please verfiy your account within 2 hours, otherwise your registration will become invalid and you will have to register again.'."'r'n";
$message .= 'Your email address: '.$post_email_address."'r'n";
$message .= 'Your Password: '.$post_password."'r'n";
$message .= 'Enjoy your stay here at '.$this->config->item('company_name')."'r'n";
$message .= 'The '.$this->config->item('company_name').' Team';

$this->email->message($message);

它更易于管理和可读。因此,您可以看到缺少单引号或双引号的位置,或者可能缺少将字符串链接到变量的句点等。

我唯一不确定的是一行.anchor()不确定这是一个函数还是其他东西,但看起来并不完整。

确保您的服务器具有 sendmail,并且在您的服务器中正确设置或安装了 sendmail 软件包

yum install sendmail

sudo apt-get install sendmail

使您的,用户电子邮件ID有效,如果发件人不存在,则不会发送电子邮件

发送测试邮件,echo "test sendmail" | sendmail xxx@yy.com

    $this->load->library('email');
    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'smtp.googlemail.com',
        'smtp_port' => 587,
        'smtp_user' => 'example@gmail.com',
        'smtp_pass' => 'password',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
    $this->email->set_newline("'r'n");

    $this->email->from('example@gmail.com', 'easyfact');
    $this->email->to('example@gmail.com');
    $this->email->cc('example@gmail.com');
    $this->email->bcc('example@gmail.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');
    $this->email->send();
    echo $this->email->print_debugger();