I'm trying to send a local mail but it always generates this error: Must issue a STARTTLS command first. I tried to find solution and I found this website which show how to configure PHP under windows to use gmail or external STMP server and I followed each step but it always generates the same error. I lost my way!!

Is there anyone who had encounter this problem before? I'm gratefull for your help...

有帮助吗?

解决方案

From the error message, it sounds like the mail server that you are trying to send this message through is requiring STARTTLS on the connection. STARTTLS is a type off connection that initially starts of unencrypted, then switches to an encrypted mode during the connection. If your PHP script that is sending the message does not support STARTTLS, and the mail server that you are trying to send the message through requires STARTTLS, then you will get this error.

To solve the problem, you can do one of the following:

1) Program your PHP script to connect to the mail server using a STARTTLS type of connection. I'm not sure if you are using PHPMailer, but if you are, PHPMailer supports STARTTLS (set the SMTPSecure property to 'tls').

2) Check if the mail server that you are trying to send through allows a different type connection (e.g. plaintext or SSL) on a different port. If so, you can change your PHP script to connect using that type of connection on that port.

其他提示

to connect to gmail, nowadays you need to get an "app password".

You must have 2-factor authentication to get an app password, which will have 16 characters.

So first, turn on 2-factor authentication: Click on your gmail icon; click 'Security'; underneath 'How you sign in to Google', enable 2 factor authentication.

Second, in the 'Security' screen, click into '2-factor authentication'; go to the very bottom of the screen and you'll see a menu for 'app passwords' where you can create a password for php mailer.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top