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

izkcnapc  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(375)

我刚刚为我的域设置了google mx记录。当我使用我的普通gmail帐户时,电子邮件会被发送,但当我使用我的gsuite帐户时,邮件不会被发送。我在sitegground上托管我的网站。但是我可以在我的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;
huwehgph

huwehgph1#

您没有附加任何错误消息,但由于它适用于您的其他Gmail帐户,请尝试检查为该帐户打开“不太安全的应用程序”访问权限是否可以解决此问题,然后返回报告。
https://myaccount.google.com/lesssecureapps(如果您登录了多个帐户,请不要忘记选择正确的帐户)。

nhjlsmyf

nhjlsmyf2#

我有类似的问题,我必须创建一个应用程序密码工作(详细信息在这里:(第10页)
创建应用程序密码后,我使用了:

$subject = 'Your subject';
    $message = 'Your body';

    //configure email settings
    $config['protocol'] = 'smtp';
    $config['smtp_host'] = 'ssl://smtp.gmail.com';
    $config['smtp_port'] = 465;
    $config['smtp_user'] = 'your@email.com';
    $config['smtp_pass'] = 'your app 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('from@email', 'Title');
    $this->email->to('to@email.com');
    $this->email->subject($subject);
    $this->email->message($message);

相关问题