Gsuite帐户不会发送电子邮件codeigniter

时间:2017-04-22 21:01:34

标签: php codeigniter email gsuite

我只为我的域设置了Google mx记录。当我使用正常的Gmail帐户时,会发送电子邮件,但是当我使用我的gsuite帐户时,邮件不会被发送。我在siteground上托管我的网站。但是,我可以通过我的gsuite帐户上的其他电子邮件帐户接收电子邮件。

$this->load->library('email');

    $subject = 'Subject';
    $message = 'My message';

    //configure email settings
    $config['protocol'] = 'smtp';
    $config['smtp_host'] = 'ssl://smtp.gmail.com';
    $config['smtp_port'] = 465
    $config['smtp_user'] = 'info@mydomain.com';
    $config['smtp_pass'] = 'my_password';
    $config['mailtype'] = 'html';
    $config['charset'] = 'utf-8';
    $config['wordwrap'] = TRUE;
    $config['newline'] = "\r\n"; //use double quotes
    $config['validation'] = TRUE;
    $this->email->initialize($config);

    //send mail
    $this->email->from('info@mydomain.com', 'MyDomainName');
    $this->email->to($to_email);
    $this->email->subject($subject);
    $this->email->message($message);

    //echo json_encode($this->email->print_debugger());
    if($this->email->send())
    return true;
    else
        return false;       

1 个答案:

答案 0 :(得分:1)

您没有附加任何错误消息,但由于它适用于您的其他Gmail帐户,请尝试检查是否启用了对安全性较低的应用程序的访问权限。对于此帐户解决了此问题并报告回来。

https://myaccount.google.com/lesssecureapps (如果您已登录多个帐户,请不要忘记选择正确的帐户。)