Kamis, 09 Januari 2014

Kirim Email melalui terminal (sendmail from terminal) linux

Hello, i will introduced why we must learn for this. This is can be powerful one you know how to use it. You can monitoring your data, backup data, and do a lot  of other useful and cool things using it. I used Ubuntu 13.04

Lets Try..


First , Install all  necessary packages (you must be a root):
apt-get install postfix libsasl2-2 ca-certificates  libsasl2-modules
  postfix wizard will ask you some question. Just select choice is Internet Site and for email using mail.kisahpemimpi.com (example).

Then, open yout postfix congig file at "main.cf":

nano /etc/postfix/main.cf

and setting at this lines to it:
relayhost = [smtp.gmail.com]:587   #this config just edit
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
 And than create file sasl_passwd:

nano /etc/postfix/sasl_passwd
 and add your email and smtp email line:
[smtp.gmail.com]:587         kisahpemimpi@gmail.com:passwordemail
  Add permision to just root
 chmod 400 /etc/postfix/sasl_passwd
 postmap /etc/postfix/sasl_passwd
  Next, validate certificates to avoid running into error. following this command :
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
 Restart Postfix
/etc/init.d/postfix restart
Now, we must installed mailutils or other mailsend client.
 Example : apt-get install mailutils
 for using thats use
echo "Haloooooo.. just tested body of email \n\n br orang ganteng" | mail -s "test email" you@gmail.com
some other usefull command is

-s Subjects of the email
-c email address for cc
-b email address for bcc

You can attach using mutt
apt-get install mutt
and
echo "This is the message" | mutt -s "aaaoooo" kisahpemimpi@gmail.com -a /tmp/image/image.jpg
Ok, thanks for reading my blog.. sorry my english so bad.. i just learn

Sumber :
http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/#Yd1DpSc4xtP4J5Sv.99
https://www.blogger.com/blogger.g?blogID=565872160529894442#editor/target=post;postID=8560783648977948448

1 komentar:

Blog Indah mengatakan...

Bole tolong kasih contohnya kak ?hehe