简体   繁体   English

使用gmail SMTP发送电子邮件,“发件​​人”字段重要吗? 我需要首先设置帐户权限吗?

[英]sending email using gmail SMTP, does the 'from' field matters? do I need to set account permission first?

I'm using codeigniter 2.1.4 to send email using gmail's smtp. 我正在使用Codeigniter 2.1.4使用gmail的smtp发送电子邮件。 Here is my config: 这是我的配置:

$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');

I wonder $this->email->from('xxxxxxx', ''); 我想知道$ this-> email-> from('xxxxxxx',''); if I should always put myaccount@gmail.com (same as the username that I use for the smtp user field. I wonder if I can change it to something like something@server-hostname. 是否应该始终输入myaccount@gmail.com(与我用于smtp用户字段的用户名相同。我想知道是否可以将其更改为诸如something @ server-hostname之类的名称。

Also I want to know if I need to set the account permission ( https://support.google.com/accounts/answer/3466521 ) before using this gmail smtp. 另外,我想知道在使用此Gmail smtp之前是否需要设置帐户权限( https://support.google.com/accounts/answer/3466521 )。 I found out that there are times that I can't send email using the exact same configuration. 我发现有些时候我无法使用完全相同的配置发送电子邮件。 I have to resend it few times (each time it will generate the gmail authentication failed error). 我必须重新发送几次(每次它将生成gmail身份验证失败错误)。 then I have to login to my myaccount@gmail.com (smtp username) account's recent activity page ( https://support.google.com/mail/answer/45938?hl=en ) and remove the unusual activity. 那么我必须登录到myaccount@gmail.com(smtp用户名)帐户的近期活动页面( https://support.google.com/mail/answer/45938?hl=zh_CN )并删除异常活动。 Once I have removed the unusual activity then I can send email without any error. 删除异常活动后,我可以发送电子邮件而不会出现任何错误。

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

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