ifybta.blogg.se

Mac os x shell script send email using sendmail via gmail
Mac os x shell script send email using sendmail via gmail








Btw this is using Gmail so if you're not.

mac os x shell script send email using sendmail via gmail

This worked for me, it was written with Lion in mind but works for Mountain Lion. The server goes back to command-mode so you can quit QUIT Now finish data with a dot as only char on a line. Now the server should answer you can start sending your mail and goes into data-mode your data Tell the server you want start sending data DATA Give one or more destinations, the are part of the command RCPT TO: Say hello plus the internetname of your provider/network, like abc.com EHLO name_of_your_networkĪ from=return address is needed, the are part of the command MAIL FROM: Open a telnet session to port 25 of the smtp server of your provider/network telnet name_or_ip_of_smtp_server 25 Then continue with the following commands, one after one. This basic way is great for testing why something goes wrong sending mail, but I think it's quite complicated to script it full proof.įirst get an command-line interface on your computer, by starting Terminal. After you contacted the server and after every command the server will answer if it accepts the command with something like "250 OK", or if not with an error message.Īll details can be found in RFC2821 - Simple Mail Transfer Protocol, Google for it. The most basic way to send mail is trough a telnet session with the smtp server of your provider/network. The last but crucial step is making sure your Keychain has the information exactly in the format that msmtp will expect it: If you use brew it will be /usr/local/bin/msmtp so the file would look like this: set sendmail="/usr/local/bin/msmtp" Then you need a ~/.mailrc file to say where the msmtp binary is located. I put mine in ~/Dropbox/Thawte Roots so that I can have it on all of my Macs. Note that tls_trust_file line should point to wherever you have downloaded and installed the certificates from. # You need to set a default account for Mail Tls_trust_file /path/to/Thawte Roots/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem # This next line should all be on one long line: # If this doesn't work, check the mstmp documentation # this next line is crucial: you have to point to the correct security certificate for GMail. # Set default values for all following accounts. The first is /usr/local/etc/msmtprc # Begin msmtprc Then the rest is just a matter of setting up the related configuration files I have written up HOWTOs for both of them:Ĭonfiguration is complicated enough that I'm not sure if I should replicate all of the steps here, but I will mention that if you use There are two programs that I am aware of which will easily allow you to configure your Mac to send email from the command line.










Mac os x shell script send email using sendmail via gmail