1

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...

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

11 Comments

I don't use PHPMailer, just a simple php script. Indeed, i need to use phpMailer?
You might want to take a look at phpmailer. It's is easy to use and simple to setup - just a few PHP files to copy to your server. See github.com/PHPMailer/PHPMailer. It's also very flexible - you can use to relay messages through a remote SMTP server on any port using any type of connection (e.g. plaintext, tls, ssl), and it also makes it simple to send more complicated types of MIME messages with attachments, HTML formatting, etc.
And if I won't use it, I want to create my own script, is thre a solution to do that?...You know, i use gmail server, smtp.gmail.com because I want to send a local mail via php
In that case, your PHP script must connect to smtp.gmail.com on port 587 using STARTTLS, or port 465 using SSL, and it must be capable of doing SMTP authentication using your gmail username and password. See support.google.com/mail/answer/13287?hl=en.
I use these configuration but i always have the same warning! Maybe, there is no solution for that kind of problem
|
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.