{"id":30,"date":"2013-10-18T17:51:45","date_gmt":"2013-10-18T17:51:45","guid":{"rendered":"http:\/\/linux.mycustomcycle.com\/?p=30"},"modified":"2015-02-19T19:35:29","modified_gmt":"2015-02-19T19:35:29","slug":"php-mail-and-gmail","status":"publish","type":"post","link":"http:\/\/linux.suriyasuneel.com\/?p=30","title":{"rendered":"PHP Mail and Gmail"},"content":{"rendered":"<p>I used to run my own mail server from my linux machine. Then due to FCC guidelines, comcast blocked the port for the smtp and pop mail, this way i cannot send or receive emails through that linux server.<\/p>\n<p>The other option is enable secure ports for the smtp and the pop and get somebody to redirect that to my server.<\/p>\n<p>So now if i have to send an email from my wordpress based server, i&#8217;m going to use the service of google and use that to relay my emails to the users.<\/p>\n<p>What do we need.<\/p>\n<p>First install sSMTP<\/p>\n<pre>apt-get install ssmpt<\/pre>\n<p>Now open the php.ini, in the \/etc\/php5\/apache2 folder and make sure that the line sendmail_path is uncommented and reads as follows<\/p>\n<pre>sendmail_path = \/usr\/sbin\/ssmtp -t<\/pre>\n<p>after this you need to restart your webserver.<\/p>\n<p>Now to configure your ssmtp.conf<\/p>\n<pre>#\r\n# Config file for sSMTP sendmail\r\n#\r\n# The person who gets all mail for userids &lt; 1000\r\n# Make this empty to disable rewriting.\r\nroot=&lt;yourgmail id&gt;\r\n\r\n# The place where the mail goes. The actual machine name is required no\r\n# MX records are consulted. Commonly mailhosts are named mail.domain.com\r\nmailhub=smtp.gmail.com:587\r\n\r\n# Where will the mail seem to come from?\r\nrewriteDomain=&lt;the website from which the email appears to come from&gt;\r\n\r\n# The full hostname\r\nhostname=&lt;the website from which the email appears to come from&gt;\r\n\r\n# Are users allowed to set their own From: address?\r\n# YES - Allow the user to specify their own From: address\r\n# NO - Use the system generated From: address\r\nFromLineOverride=YES\r\nAuthUser=&lt;the gmail account you are using to relay through&gt;\r\nAuthPass=&lt;gmail password&gt;\r\nUseSTARTTLS=yes\r\nUseTLS=yes\r\nAuthMethod=LOGIN<\/pre>\n<p>Now the other config file revaliases<\/p>\n<pre># sSMTP aliases\r\n#\r\n# Format: local_account:outgoing_address:mailhub\r\n#\r\n# Example: root:your_login@your.domain:mailhub.your.domain[:port]\r\n# where [:port] is an optional port number that defaults to 25.\r\nroot::smtp.gmail.com:587\r\nmainuser::smtp.gmail.com:587<\/pre>\n<p>Now test your setup from the command line<\/p>\n<pre>echo test | sendmail -v -s \"testing ssmtp setup\" &lt;any_email_id&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I used to run my own mail server from my linux machine. Then due to FCC guidelines, comcast blocked the port for the smtp and pop mail, this way i cannot send or receive emails through that linux server. The other option is enable secure ports for the smtp and the pop and get somebody [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/30"}],"collection":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":3,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":33,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions\/33"}],"wp:attachment":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}