正确的smtp认证参数设置是什么?


What is the correct parameter setting for smtp auth

我有这样的脚本:

  // Define SMTP Parameters
  $params = array();
  $params['host']     = 'mail.mydomain.com';
  $params['port']     = '25';
  $params['auth']     = 'true';
  $params['username'] = 'valid@mydomain.com'; // this needs to be a legitimate mail account on the server and not an alias
  $params['password'] = 'abcdef';
  // Create the mail object using the Mail::factory method
  include('Mail.php');
  $mail_object =& Mail::factory('smtp', $params);

params['auth']设置为'true'时似乎不工作,但设置为'PLAIN'时似乎工作。奇怪的是,文档只说明$params["auth"] - Whether or not to use SMTP authentication. Default is FALSE.,这听起来像是您可以使用FALSE'PLAIN'

可能的认证方法有:

  • 'DIGEST-MD5'
  • 'CRAM-MD5'
  • 'LOGIN'
  • 'PLAIN'

false不需要认证。

http://pear.github.io/Net_SMTP/smtp-authentication

PS:您可能已经注意到,使用了pear/Mail包。顺便说一下,它是相对较旧的,最新的变化是在2010年