1

I have an Ubuntu Server v18.10. I am only allowed to install openssh, openvpn, & curl. I have scripts that need to send emails. I have a windows background & I am beginner\intermediate for linux. I show below that I can get curl to work with gmail & I can get office365 to work with powershell. However, I get the below code with curl using office365. I tried googling the error but did not see any relevant articles. Any help with better understandings the error code &/or fixing the command I am using is appreciated. Also if Ubuntu server has a built in way to send emails, what is this way?

I can send emails with curl using gmail. However, using office365, I receive the below error. How can I get curl to work with office365?

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

This works correctly: curl --url 'smtps://smtp.gmail.com:465' --ssl-reqd --mail-from 'mysendemail@gmail.com' --mail-rcpt 'myreceiveemail' --upload-file '/Message' -K /cred

This does not work: curl --url 'smtps://smtp.office365.com:587' --ssl-reqd --mail-from 'mysendemail' --mail-rcpt 'myreceiveemail' --upload-file '/Message' -K /cred or curl --url 'smtps://smtp.office365.com:587' --tlsv1.2 --mail-from 'mysendemail' --mail-rcpt 'myreceiveemail' --upload-file '/Message' -K /cred

The cred file contains: --user email:password

I can use Office365 to send emails with PowerShell in windows so I know the url, port, and credentials are correct.

Send-Mailmessage -smtpServer smtp.office365.com -port 587 -UseSsl -from $from -to "$emailaddress","$AlternateEmailAddresses" -subject $subject -body $body -bodyasHTML -Credential $CredObject

To send emails using Office365 server: SMTP Host: smtp.office365.com SMTP Port: 587 SSL Protocol: OFF TLS Protocol: ON SMTP Username: (your Office365 username) SMTP Password: (your Office365 password)

curl --version curl 7.61.0 (x86_64-pc-linux-gnu) libcurl/7.61.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.4) nghttp2/1.32.1 librtmp/2.3 Release-Date: 2018-07-11 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.