{"id":828,"date":"2014-10-24T08:58:36","date_gmt":"2014-10-24T11:58:36","guid":{"rendered":"http:\/\/blog.abratel.com.br\/?p=828"},"modified":"2014-10-24T09:01:08","modified_gmt":"2014-10-24T12:01:08","slug":"configuring-send-emails-using-gmail-account-in-with-ssmtp","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=828","title":{"rendered":"Configuring send emails using GMail Account in with SSMTP"},"content":{"rendered":"<p>Today i will show how to send an emails from CentOS  using a GMAIL account. For this, we will use mailx and ssmtp.<\/p>\n<p>Go to Gmail and enable this (ACCOUNT):<\/p>\n<p><a href=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/Imagem-18.png\"><img loading=\"lazy\" src=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/Imagem-18-300x174.png\" alt=\"Imagem 18\" width=\"300\" height=\"174\" class=\"alignnone size-medium wp-image-829\" srcset=\"https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/Imagem-18-300x174.png 300w, https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/Imagem-18-600x349.png 600w, https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/Imagem-18.png 750w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>1. Disable POSTFIX (You can remove, i choose disable)<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\troot@hostname]# service postfix stop ; chkconfig postfix off<\/pre>\n<p><strong>2. Install SSMTP and MailX<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> [root@hostname]# yum install mailx ssmtp -y <\/pre>\n<p>in centos 7 i needed install manually: <a href=\"http:\/\/pkgs.org\/download\/ssmtp\">http:\/\/pkgs.org\/download\/ssmtp<\/a> (centos6)<\/p>\n<p><strong>3. Configure SSMTP \/etc\/ssmtp\/ssmtp.conf file to looks like<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot=YOUREMAIL@gmail.com\r\nmailhub=smtp.gmail.com:587\r\nrewriteDomain=gmail.com\r\nhostname=YOURMACHINEHOSTNAME;\r\nUseTLS=Yes\r\nUseSTARTTLS=Yes\r\nAuthUser=YOUREMAIL@gmail.com\r\nAuthPass=YOUR PASSWORD;\r\nFromLineOverride=YES\r\n# This solved if you get a ssmtp: Cannot open smtp.gmail.com:587 when try to send an email\r\n# if you enabled uncommenting DEBUG=Yes line and your \/var\/log\/maillog show\r\n# SSL not working: certificate verify failed (20) Uncomment the following line but first VERIFY FILE EXISTS\r\nTLS_CA_File=\/etc\/pki\/tls\/certs\/ca-bundle.crt\r\n #DEBUG=Yes\r\n<\/pre>\n<p><strong>4. Configure SSMTP \/etc\/ssmtp\/revaliases file to looks like<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\troot:YOUREMAIL@gmail.com:smtp.gmail.com:587 <\/pre>\n<p><strong>5. Configure Alternatives (command mail)<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\t[root@hostname]# alternatives --config mta <\/pre>\n<p>There are 2 programs which provide &#8216;mta&#8217;.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n  Selection    Command\r\n-----------------------------------------------\r\n+  1          \/usr\/sbin\/sendmail.postfix\r\n* 2           \/usr\/sbin\/sendmail.ssmtp\r\n <\/pre>\n<p>Enter to keep the current selection[+], or type selection number: 2 (press ENTER)<\/p>\n<p><strong>6. Test Email<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\t [root@hostname]# echo Hi from command line | mail youremail@youremailhost.com <\/pre>\n<p><strong>7. Allow more users to send emails using mail<\/strong><\/p>\n<p>If you want to allow to more users to send emails using it, just add user to the mail group<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\t[root@hostname]# gpasswd -a USER mail <\/pre>\n<p>and add a line to the \/etc\/ssmtp\/revaliases<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> USER:YOUR EMAIL@gmail.com:smtp.gmail.com:587 <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today i will show how to send an emails from CentOS using a GMAIL account. For this, we will use mailx and ssmtp. Go to Gmail and enable this (ACCOUNT): 1. Disable POSTFIX (You can remove, i choose disable) 2. Install SSMTP and MailX in&#8230;<\/p>\n","protected":false},"author":1,"featured_media":830,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/828"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=828"}],"version-history":[{"count":3,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/828\/revisions"}],"predecessor-version":[{"id":832,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/828\/revisions\/832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/media\/830"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}