title: xampp php send mail
body: <p>I searched on stackoverflow and google to find how to setup <code>xampp</code>, <code>mercury</code> and <code>php</code> code to send mail with window server 2008 r2. </p>
  
  <p>And with tutorial found out I can send mail by using <code>Mail::factory</code> with <code>smtp.gmail.com</code>, and also can send mail by using <strong>Mercury</strong> (<kbd>File</kbd> -> <kbd>Send mail message</kbd>) with <code>my_email_address@my_domain_name.com</code> registered in Mercury. So I try to send mail by using <code>php</code> code. But it is sill not working in my case.   </p>
  
  <p>Here are my configs:</p>
  
  <p><strong>C:/xampp/apache/php.ini</strong></p>
  
  <pre><code>sendmail_path = "\xampp\sendmail\sendmail.exe -t -i"
  </code></pre>
  
  <p><strong>sendmail.ini</strong></p>
  
  <pre><code>smtp_server=my_domain_name.com
  smtp_port=25
  error_logfile=error.log
  debug_logfile=debug.log
  auth_username=my_email_address@my_domain_name.com
  auth_password=my_password
  force_sender=my_email_address@my_domain_name.com
  hostname=my_domain_name.com
  </code></pre>
  
  <p><strong>code php</strong></p>
  
  <pre><code>$to = $email;
  $subject = "Hello";
  $message = "How are you ?";
  $from = "my_email_address@my_domain_name.com";
  $headers = "From:" . $from;
  $result = mail($to,$subject,$message,$headers);
  
  if($result){
      echo "Mail Sent." . $result;
  }
  else{
      echo "Failure." . $result;
  }
  </code></pre>
  
  <p>I check in <code>C:\xampp\sendmail\debug.log</code> and get error</p>
  
  <pre><code>--- MESSAGE END ---
  12/12/31 06:46:04 ** Connecting to my_domain_name.com:25
  12/12/31 06:46:06 ** Disconnected.
  12/12/31 06:46:06 ** Disconnected.
  12/12/31 06:46:06 ** Disconnected.
  12/12/31 06:46:06 ** Socket Error # 10061&lt;EOL&gt;Connection refused.
  </code></pre>
  
  <p>where am I wrong ? Would you please here help me ?</p>