SMTP server response: 530 5.7.0 Must issue a STARTTLS command first

后端 未结 9 689
生来不讨喜
生来不讨喜 2020-11-28 13:25

SMTP server response: 530 5.7.0 Must issue a STARTTLS command first

I get this error message when i use mail() function in php script file...

I m using gmail

相关标签:
9条回答
  • 2020-11-28 14:01

    First, make sure you PHP installation has SSL support (look for an "openssl" section in the output from phpinfo()).

    You can set the following settings in your PHP.ini:

    ini_set("SMTP","ssl://smtp.gmail.com");
    ini_set("smtp_port","465");
    
    0 讨论(0)
  • 2020-11-28 14:01

    Problem Solved,

    I edited the file /etc/postfix/master.cf

    and commented

    -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
    

    and changed the line from

    -o smtpd_tls_security_level=encrypt 
    

    to

    -o smtpd_tls_security_level=may
    

    And worked on fine

    0 讨论(0)
  • 2020-11-28 14:03

    I am going to share my way and it worked for me after implementing following:

    Open Php.ini file and fill the all the values in the respective fields by taking ref from Gmail SMTP Settings

    Remove comments from the [mail function] Statements which are instructions to the smtp Server and Match their values.

    Also the sendmail SMTP server is a Fake server. Its nothing beside a text terminal (Try writing anything on it. :P). It will use gmail s,tp to send Mails. So configure it correctly by matching Gmail SMTP settings:

    smtp.gmail.com
    Port: 587
    
    0 讨论(0)
  • 2020-11-28 14:03

    Blockquote

    I then modified the php.ini file to use it (commented out the other lines):
    
    [mail function]
    ; For Win32 only.
    ; SMTP = smtp.gmail.com
    ; smtp_port = 25
    
    ; For Win32 only.
    ; sendmail_from = <e-mail username>@gmail.com
    
    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
    
    Ignore the "For Unix only" comment, as this version of sendmail works for Windows.
    
    You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:
    
    [sendmail]
    
    smtp_server=smtp.gmail.com
    smtp_port=25
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username=<username>
    auth_password=<password>
    force_sender=<e-mail username>@gmail.com
    
    http://byitcurious.blogspot.com.br/2009/04/solving-must-issue-starttls-command.html
    
    > Blockquote
    
    0 讨论(0)
  • 2020-11-28 14:11

    I had a false response for the following:

    fputs($connection, 'STARTTLS'.$newLine);
    

    turns out I use the wrong connection variable, so I just had to change it to:

    fputs($smtpConnect, 'STARTTLS'.$newLine);
    

    If using TLS remember to put HELO before and after:

    fputs($smtpConnect, 'HELO '.$localhost . $newLine);
    $response = fgets($smtpConnect, 515);
    if($secure == 'tls')
    {
        fputs($smtpConnect, 'STARTTLS'.$newLine);
        $response = fgets($smtpConnect, 515);
    stream_socket_enable_crypto($smtpConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
    
    // Say hello again!
        fputs($smtpConnect, 'HELO '.$localhost . $newLine);
        $response = fgets($smtpConnect, 515);
    }
    
    0 讨论(0)
  • 2020-11-28 14:12

    Out of the box Swift Mailer can't do STARTTLS, however some nice guys have written a patch for it.

    I found patching it was a bit of a chore (probably went about it the wrong way), so have zipped it up ready for download here: Swift Mailer with STARTTLS

    0 讨论(0)
提交回复
热议问题