简体   繁体   English

使用Codeigniter从Xampp发送电子邮件

[英]Send email from xampp using codeigniter

I'm running into an error when trying to send an email using codeigniter. 尝试使用codeigniter发送电子邮件时遇到错误。 I've tested the function I'm using with an online server but it still throws the same error. 我已经测试了在线服务器上使用的功能,但仍然会引发相同的错误。

Below is my function: 下面是我的功能:

//send email
    function sendEmail() {
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'email', // change it to yours
            'smtp_pass' => 'pswd', // change it to yours
            'mailtype' => 'html',
            'charset' => 'iso-8859-1',
            'wordwrap' => TRUE
        );

        $message = 'Test message';
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('zzz@gmail.com'); // change it to yours
        $this->email->to('xxx@gmail.com'); // change it to yours
        $this->email->subject('Resume from JobsBuddy for your Job posting');
        $this->email->message($message);
        if ($this->email->send()) {
            echo 'Email sent.';
        } else {
            show_error($this->email->print_debugger());
        }
    }

I'm getting the below error: 我收到以下错误:

Failed to authenticate password. 无法验证密码。 Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 错误:534-5.7.14,请通过Web浏览器和534-5.7.14登录,然后重试。 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 w84sm8590284ioi.20 - gsmtp Unable to send email using PHP SMTP. 534-5.7.14了解更多信息,位于534 5.7.14 https://support.google.com/mail/answer/78754 w84sm8590284ioi.20-gsmtp无法使用PHP SMTP发送电子邮件。 Your server might not be configured to send mail using this method. 您的服务器可能未配置为使用此方法发送邮件。

Kindly assist 请协助

The answer isn't code related but due to the fact that your Gmail account must be enabled to permit smtp/IMAP access. 答案与代码无关,但是由于必须启用您的Gmail帐户才能允许smtp / IMAP访问,所以答案与代码无关。 From the Google help Center : Google帮助中心

  1. Sign in to the Gmail web interface. 登录Gmail网络界面。
  2. Open the 'Forwarding and POP/IMAP' tab on your 'Settings' page, and configure IMAP or POP. 在“设置”页面上打开“转发和POP / IMAP”标签,然后配置IMAP或POP。
  3. After enabling this in Gmail, make sure you click 'Save Changes' so Gmail can communicate with your mail client 在Gmail中启用此功能后,请确保单击“保存更改”,以便Gmail可以与您的邮件客户端通信

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM