Smtp电子邮件不发送直播

时间:2016-07-19 09:32:19

标签: php codeigniter smtp

在我的项目中,我发送了直播电子邮件,但它显示了问题

public function send_mail($to_email, $mail_subject, $mail_message, $attachment='')
{

    $msg_body='
            <!DOCTYPE html>
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Test</title>
            </head>
            <body>
            <table width="80%" border="0" style="" cellspacing="0" cellpadding="0" align="center">
            </table></body></html>';
    $config['protocol']    = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.gmail.com';
    $config['smtp_port']    = '465';
    $config['smtp_timeout'] = '7';
    $config['smtp_user']    = 'test@gmail.com';
    $config['smtp_pass']    = 'Admin@123@';
    $config['charset']    = 'utf-8';
    $config['newline']    = "\r\n";
    $config['mailtype'] = 'html'; // or html
    $config['validation'] = TRUE; // bool whether to validate email or not
    $this->email->initialize($config);
    $this->email->from('Test@test.com', 'www.test.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');
    $this->email->send();
    echo $this->email->print_debugger();
    exit;
}

我收到了这样的错误

致命错误:在/中的非对象上调用成员函数initialize() 我初始化工作正常。它在我的本地服务器上运行良好。

                <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

            <h4>A PHP Error was encountered</h4>

            <p>Severity: Notice</p>
            <p>Message:  Undefined property: airport_mailer::$email</p>
            <p>Filename: libraries/airport_mailer.php</p>
            <p>Line Number: 109</p>

            </div><br />
            <b>Fatal error</b>:  Call to a member function initialize() on a non-object in <b>/home/goairport/public_html
            /application/libraries/airport_mailer.php</b> on line <b>109</b><br />

1 个答案:

答案 0 :(得分:0)

我认为您错过了加载display: flex; flex-direction: column; 。只需在email library之前添加此行即可加载$this->email->initialize($config);

email library

另请参阅:CodeIgniter Sending Email