PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 4, 2022

[FIXED] What are the Curl SMTP command line arguments to support GMail TLS/STARTTLS vs SSL

 July 04, 2022     command-line, curl, email, smtp, ssl     No comments   

Issue

I am using Curl.exe in an application to send emails. I need to support most major email servers. GMail exposes the following ports and Authentication methods.

  • TLS/STARTTLS (sometimes called Explicit TLS): uses port 587
  • SSL (sometimes called Implicit TLS): uses port 465

I have gotten the Explicit TLS to work using the following command line:

C:\>curl smtp://smtp.gmail.com:587 -v --mail-from "my.mail@gmail.com" --mail-rcpt 
"your.mail@x.com" --ssl -u my.mail@gmail.com:password -T "c:\test.txt" -k --anyauth

I have tried the following to get ImplicitTLS to work, but it is not.

C:\>curl smtp://smtp.gmail.com:465 -v --mail-from "my.mail@gmail.com" --mail-rcpt 
"your.mail@x.com" --ssl -u my.mail@gmail.com:password -T "c:\test.txt" -k --anyauth

What are the proper command line parameters to get SSL/Implicit TLS to work?


Solution

Use smtps:// for SMTPS (i.e. SMTP on top of an existing SSL/TLS connection).

This works:

curl smtps://smtp.gmail.com:465 -v

I would also use --ssl-reqd for the explicit STARTTLS connection to make sure SSL/TLS is used when you expect it to be (downgrade attacks would be possible otherwise).

Don't use -k either, check the server certificate: see http://curl.haxx.se/docs/sslcerts.html



Answered By - Bruno
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,213,523

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing