1

I searched on stackoverflow and google to find how to setup xampp, mercury and php code to send mail with window server 2008 r2.

And with tutorial found out I can send mail by using Mail::factory with smtp.gmail.com, and also can send mail by using Mercury (File -> Send mail message) with my_email_address@my_domain_name.com registered in Mercury. So I try to send mail by using php code. But it is sill not working in my case.

Here are my configs:

C:/xampp/apache/php.ini

sendmail_path = "\xampp\sendmail\sendmail.exe -t -i"

sendmail.ini

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 php

$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;
}

I check in C:\xampp\sendmail\debug.log and get error

--- 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<EOL>Connection refused.

where am I wrong ? Would you please here help me ?

AnFi
  • 10,493
  • 3
  • 23
  • 47
whitebox
  • 21
  • 1
  • 1
  • 2
  • 1
    your `debug.log` `Socket Error [..] Connection refused` indicates, that no SMTP server is actually answering on `my_domain_name.com:25` make sure, there is a smtp server up and running and port 25 is not blocked by a firewall. – Michel Feldheim Dec 31 '12 at 12:10
  • @MichelFeldheim Thank you for your answer , I check in my window firewall , SMTP port 25 is allow in Inbound rules , and still not working . How can I know smtp server up and running ? – whitebox Dec 31 '12 at 12:24

2 Answers2

3

Most time is the problem the ip of the server. Because most provider dont allow traffic from dynamic ips, from servers with no god spf record ...

A solution would be, make a gmail account, and forward all traffic over gmail or an house internal exchange server. XAMPP Sendmail using Gmail account

Community
  • 1
  • 1
GreenRover
  • 1,486
  • 1
  • 14
  • 33
  • Thank you for your answer . I can send mail with my gmail account but don't want to use gmail account to send mail. I want to create new account for my domain , something like support@my_domain_name.com to send mail . – whitebox Dec 31 '12 at 12:26
  • Where do you host your domain? Didt you allready have an email provider? Create there an account and use the smtp login data for you sendmail.ini – GreenRover Dec 31 '12 at 14:21
  • Thank you for your answer . Is this mean I need to buy an email for my domain ? I created an email for my domain ( ex : support@my_domain_name.com ) in Mercury , and succeed send mail from this email address to some yahoo mail by using Mercury ( File->Send mail message ) . So why I need to buy an email for my domain ? Please explain me , I appreciate. – whitebox Jan 01 '13 at 10:42
  • I buy a domain name from www.domain.com – whitebox Jan 01 '13 at 12:43
  • Because it is not possible to run a email server on a Home server. Better use Google als with your domain. – GreenRover Jan 01 '13 at 19:02
0

Please follow instructions as mentioned in following link:-

http://system66.blogspot.com/2010/01/how-to-send-mail-from-localhost-with.html

Mudaser Ali
  • 3,989
  • 3
  • 25
  • 27