{"id":36,"date":"2010-12-01T12:12:12","date_gmt":"2010-12-01T04:12:12","guid":{"rendered":"http:\/\/www.evercute.com\/techblog\/?p=36"},"modified":"2010-12-01T12:13:43","modified_gmt":"2010-12-01T04:13:43","slug":"how-to-send-email-from-a-php-script-using-smtp-authentication","status":"publish","type":"post","link":"https:\/\/www.evercute.com\/techblog\/?p=36","title":{"rendered":"How to Send Email from a PHP Script Using SMTP Authentication"},"content":{"rendered":"<p>Install pear:mail, pear:net_smtp<\/p>\n<p>code:<br \/>\nrequire_once &#8220;Mail.php&#8221;;<\/p>\n<p>$from = &#8220;Sandra Sender &#8220;;<br \/>\n$to = &#8220;Ramona Recipient &#8220;;<br \/>\n$subject = &#8220;Hi!&#8221;;<br \/>\n$body = &#8220;Hi,\\n\\nHow are you?&#8221;;<\/p>\n<p>$host = &#8220;mail.example.com&#8221;;<br \/>\n$username = &#8220;smtp_username&#8221;;<br \/>\n$password = &#8220;smtp_password&#8221;;<\/p>\n<p>$headers = array (&#8216;From&#8217; =&gt; $from,<br \/>\n&#8216;To&#8217; =&gt; $to,<br \/>\n&#8216;Subject&#8217; =&gt; $subject);<br \/>\n$smtp = Mail::factory(&#8216;smtp&#8217;,<br \/>\narray (&#8216;host&#8217; =&gt; $host,<br \/>\n&#8216;auth&#8217; =&gt; true,<br \/>\n&#8216;username&#8217; =&gt; $username,<br \/>\n&#8216;password&#8217; =&gt; $password));<\/p>\n<p>$mail = $smtp-&gt;send($to, $headers, $body);<\/p>\n<p>if (PEAR::isError($mail)) {<br \/>\necho(&#8221;<\/p>\n<p>&#8221; . $mail-&gt;getMessage() . &#8221;<\/p>\n<p>&#8220;);<br \/>\n} else {<br \/>\necho(&#8221;<\/p>\n<p>Message successfully sent!<\/p>\n<p>&#8220;);<br \/>\n}<br \/>\n?&gt;<\/p>\n<p>Ref: <a href=\"http:\/\/email.about.com\/od\/emailprogrammingtips\/qt\/PHP_Email_SMTP_Authentication.htm\">http:\/\/email.about.com\/od\/emailprogrammingtips\/qt\/PHP_Email_SMTP_Authentication.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install pear:mail, pear:net_smtp code: require_once &#8220;Mail.php&#8221;; $from = &#8220;Sandra Sender &#8220;; $to = &#8220;Ramona Recipient &#8220;; $subject = &#8220;Hi!&#8221;; $body = &#8220;Hi,\\n\\nHow are you?&#8221;; $host = &#8220;mail.example.com&#8221;; $username = &#8220;smtp_username&#8221;; $password = &#8220;smtp_password&#8221;; $headers = array (&#8216;From&#8217; =&gt; $from, &#8216;To&#8217; &hellip; <a href=\"https:\/\/www.evercute.com\/techblog\/?p=36\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[15],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-php","tag-php-smtp-ssl"],"_links":{"self":[{"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":2,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":39,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions\/39"}],"wp:attachment":[{"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evercute.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}