Must Issue a Starttls Command First

Must issue a STARTTLS command first

You are probably attempting to use Gmail's servers on port 25 to deliver mail to a third party over an unauthenticated connection. Gmail doesn't let you do this, because then anybody could use Gmail's servers to send mail to anybody else. This is called an open relay and was a common enabler of spam in the early days. Open relays are no longer acceptable on the Internet.

You will need to ask your SMTP client to connect to Gmail using an authenticated connection, probably on port 587.

Telnet smtp.mail - must issue STARTTLS command first

You're required to start encrypting the connection first. This is done using the STARTTLS command.

You can use the following command instead of telnet:

openssl s_client -starttls smtp -ign_eof -crlf -connect smtp.gmail.com:587

It works like the telnet command, but takes care of starting the encryption first.

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

To be fair, your script is doing exactly what you're asking it to, but gmail doesn't like that!

Your problems stem from this line:

$mail->Host = gethostbyname('smtp.gmail.com');

This will set Host to an IP address, and it has been suggested in the past as a workaround for those using IPv6 (which gmail doesn't like), because it always returns an IPv4 address.

However, it causes another problem: there is no longer a host name to verify a certificate against, and TLS connections fail. So this leads you try to turn off TLS:

$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;

Having no TLS means you can't authenticate, so you turn that off:

$mail->SMTPAuth = false;

But gmail (very sensibly) won't let you send without authentication, and so you're stuck.

The solution then is to undo all that, revert to the code as provided in the gmail example.

How to resolve ‘530 5.7.0 Must issue a STARTTLS command first. o63-v6sm4041934ywc.36 - gsmtp\n’ for elasticsearch?

It's solved now, all I need to do is enable TLS authentication.

Here is my updated content of elasticsearch.yml:

xpack.security.enabled: false 
xpack.notification.email.account:
standard_account:
profile: standard
smtp:
auth: true
starttls.enable: true
starttls.required: true
host: smtp.gmail.com
port: 587
user: <mailId>
password: <passowrd>

Getting Must issue a STARTTLS command first when trying to send email

I used Alexander Pomozov's solution to talk to Gmail from my Rails app. I believe the original article is gone but someone has reproduced the Google cache over here.

lib/smtp_tls.rb

require "openssl"
require "net/smtp"

Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret

sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
#@socket.debug_output = STDERR #@debug_output

check_response(critical { recv_response() })
do_helo(helodomain)

if starttls
raise 'openssl library not installed' unless defined?(OpenSSL)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
#@socket.debug_output = STDERR #@debug_output
do_helo(helodomain)
end

authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not @socket.closed?
@socket = nil
end
end

def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end

def starttls
getok('STARTTLS') rescue return false
return true
end

def quit
begin
getok('QUIT')
rescue EOFError, OpenSSL::SSL::SSLError
end
end
end

config/environment.rb

(add after everything else)

    require “smtp_tls”

ActionMailer::Base.smtp_settings = {
:address => “smtp.gmail.com”,
:port => 587,
:authentication => :plain,
:user_name => “someone@openrain.com”,
:password => ’someonesPassword’
}

Use ActionMailer as normal.

(530, '5.7.0 Must issue a STARTTLS command first. 135sm7372342lfb.28 - gsmtp',u'mail id)

Try adding

EMAIL_USE_TLS = True 

to your settings page where you have all your email settings. Also make sure that your gmail SMTP has the right login details and make sure that Django is using SMTP mail server.



Related Topics



Leave a reply



Submit