【问题标题】:sending email using gmail SMTP, does the 'from' field matters? do I need to set account permission first?使用 gmail SMTP 发送电子邮件,“发件​​人”字段重要吗?我需要先设置帐户权限吗?
【发布时间】:2014-05-24 19:30:23
【问题描述】:

我正在使用 codeigniter 2.1.4 通过 gmail 的 smtp 发送电子邮件。这是我的配置:

$config['protocol'] = 'smtp';
$config['smtp_crypto'] = 'ssl';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'myaccount@gmail.com';
$config['smtp_pass'] = 'my secret password';
$config['smtp_port'] = '465';
$config['newline'] = "\r\n";

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

$this->email->from('xxxxxxx', '');
$this->email->to('johndoe@gmail.com');

$this->email->subject(' CodeIgniter Rocks Socks ');
$this->email->message('Hello World');

我想知道 $this->email->from('xxxxxxx', '');如果我应该始终输入 myaccount@gmail.com(与我用于 smtp 用户字段的用户名相同。我想知道是否可以将其更改为 something@server-hostname。

我还想知道在使用这个 gmail smtp 之前是否需要设置帐户权限 (https://support.google.com/accounts/answer/3466521)。 我发现有时我无法使用完全相同的配置发送电子邮件。我必须重新发送几次(每次都会生成 gmail 身份验证失败错误)。然后我必须登录到我的 myaccount@gmail.com(smtp 用户名)帐户的最近活动页面(https://support.google.com/mail/answer/45938?hl=en)并删除异常活动。一旦我删除了异常活动,我就可以毫无错误地发送电子邮件。

【问题讨论】:

    标签: php codeigniter smtp gmail codeigniter-2


    【解决方案1】:

    这个问题类似于:

    Sending email with gmail smtp with codeigniter email library

    how to correct way to send email using codeigniter

    您可能会得到您需要的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-18
      • 2012-03-30
      • 2011-12-16
      • 2022-07-02
      • 1970-01-01
      • 2010-10-08
      • 2017-10-22
      相关资源
      最近更新 更多