<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.d3xt3r01.tk//index.php?action=history&amp;feed=atom&amp;title=Send_mails_via_SMTP_with_auth</id>
	<title>Send mails via SMTP with auth - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.d3xt3r01.tk//index.php?action=history&amp;feed=atom&amp;title=Send_mails_via_SMTP_with_auth"/>
	<link rel="alternate" type="text/html" href="https://wiki.d3xt3r01.tk//index.php?title=Send_mails_via_SMTP_with_auth&amp;action=history"/>
	<updated>2026-05-05T15:52:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.d3xt3r01.tk//index.php?title=Send_mails_via_SMTP_with_auth&amp;diff=373&amp;oldid=prev</id>
		<title>Admin: New page: ==WHY==  Because mail() doesn&#039;t always give the right results, also one might want to use it&#039;s own SMTP server !  ==HOW==  Using PEAR&#039;s Mail class !  &lt;source lang=&quot;php&quot;&gt; &lt;?php require_once...</title>
		<link rel="alternate" type="text/html" href="https://wiki.d3xt3r01.tk//index.php?title=Send_mails_via_SMTP_with_auth&amp;diff=373&amp;oldid=prev"/>
		<updated>2010-02-24T08:29:25Z</updated>

		<summary type="html">&lt;p&gt;New page: ==WHY==  Because mail() doesn&amp;#039;t always give the right results, also one might want to use it&amp;#039;s own SMTP server !  ==HOW==  Using PEAR&amp;#039;s Mail class !  &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt; &amp;lt;?php require_once...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==WHY==&lt;br /&gt;
&lt;br /&gt;
Because mail() doesn&amp;#039;t always give the right results, also one might want to use it&amp;#039;s own SMTP server !&lt;br /&gt;
&lt;br /&gt;
==HOW==&lt;br /&gt;
&lt;br /&gt;
Using PEAR&amp;#039;s Mail class !&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require_once &amp;quot;Mail.php&amp;quot;;&lt;br /&gt;
$from = &amp;quot;Name&amp;lt;mail@here.com&amp;gt;&amp;quot;; // This is how some use to forge the &amp;quot;From&amp;quot; Header. The Name isn&amp;#039;t really required, an just set mail@here.com only without the &amp;lt;&amp;gt; part !&lt;br /&gt;
$to = &amp;quot;Name&amp;lt;destination@here.com&amp;gt;&amp;quot;; // Name isn&amp;#039;t really required. You can just set destination@here.com only without the &amp;lt;&amp;gt; part !&lt;br /&gt;
$subject = &amp;quot;Hi!&amp;quot;;&lt;br /&gt;
$body = &amp;quot;Hi,\n\nHow are you?&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Server auth info&lt;br /&gt;
$host = &amp;quot;smtp.gmail.com&amp;quot;;&lt;br /&gt;
$username = &amp;quot;auth@user.com&amp;quot;;&lt;br /&gt;
$password = &amp;quot;p4ssw0rdg03sh3r3&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$headers = array (&amp;#039;From&amp;#039; =&amp;gt; $from, &amp;#039;To&amp;#039; =&amp;gt; $to, &amp;#039;Subject&amp;#039; =&amp;gt; $subject);&lt;br /&gt;
$smtp = Mail::factory(&amp;#039;smtp&amp;#039;, array (&amp;#039;host&amp;#039; =&amp;gt; $host, &amp;#039;auth&amp;#039; =&amp;gt; true, &amp;#039;username&amp;#039; =&amp;gt; $username, &amp;#039;password&amp;#039; =&amp;gt; $password));&lt;br /&gt;
$mail = $smtp-&amp;gt;send($to, $headers, $body);&lt;br /&gt;
&lt;br /&gt;
if(PEAR::isError($mail)){&lt;br /&gt;
	echo(&amp;quot;&amp;lt;p&amp;gt;&amp;quot;.$mail-&amp;gt;getMessage().&amp;quot;&amp;lt;/p&amp;gt;&amp;quot;);&lt;br /&gt;
}else{&lt;br /&gt;
	echo(&amp;quot;&amp;lt;p&amp;gt;Message successfully sent!&amp;lt;/p&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: PHP]]&lt;br /&gt;
[[Category: PEAR]]&lt;br /&gt;
[[Category: SMTP]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>