Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem in mail sending

Member
 
Join Date: May 2008
Posts: 118
#1: Jan 31 '09
Hi,

i placed the php in windows server 2003 manually , set the path in Environmental variables , and place the php.ini file in windows.
Now php works fine in my server sytem.When i write the mail sending code and run that program mail didn't sent.
in my php.ini file consists the
smtp=localhost
smtp_port=25
sendmail_from=me@localhost.com
In my smtp settings:
Internet Information Services->righclick on default virtual smtp server->properties->Access tab->Relay->add the my system IP address and 127.0.0.1 ip address .

We think there is no problem from smtp settings.Because we run the jsp mail sending in same server machine .It works fine and mail sent .

Here is the php code we have used
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to ="email@domain.com";
  3. $subject = "Test Mail";
  4. $message = "hello how are you";
  5. $headers = "MIME-Version: 1.0\n";
  6. $headers .= "Content-type: text/html; charset=iso-8859-1\n";
  7. $headers .= "X-Priority: 3\n";
  8. $headers .= "X-MSMail-Priority: Normal\n";
  9. $from = "me@example.com";
  10. $headers .= "From: $from";
  11. mail($to,$subject,$message,$headers);
  12. ?>
  13.  
Please tell that whats the probelem in that.

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,662
#2: Jan 31 '09

re: Problem in mail sending


PHP's mail() function doesn't use the smtp server. (see manual entry below)

if you want to use your smtp server, try Swift Mailer or PHP Mailer
Quote:

Originally Posted by php.net

Requirements

For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.

dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#3: Feb 1 '09

re: Problem in mail sending


Does your smtp server require a username and password or authentication?


Dan

Quote:

Originally Posted by swethak View Post

Hi,

i placed the php in windows server 2003 manually , set the path in Environmental variables , and place the php.ini file in windows.
Now php works fine in my server sytem.When i write the mail sending code and run that program mail didn't sent.
in my php.ini file consists the
smtp=localhost
smtp_port=25
sendmail_from=me@localhost.com
In my smtp settings:
Internet Information Services->righclick on default virtual smtp server->properties->Access tab->Relay->add the my system IP address and 127.0.0.1 ip address .

We think there is no problem from smtp settings.Because we run the jsp mail sending in same server machine .It works fine and mail sent .

Here is the php code we have used

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to ="email@domain.com";
  3. $subject = "Test Mail";
  4. $message = "hello how are you";
  5. $headers = "MIME-Version: 1.0\n";
  6. $headers .= "Content-type: text/html; charset=iso-8859-1\n";
  7. $headers .= "X-Priority: 3\n";
  8. $headers .= "X-MSMail-Priority: Normal\n";
  9. $from = "me@example.com";
  10. $headers .= "From: $from";
  11. mail($to,$subject,$message,$headers);
  12. ?>
  13.  
Please tell that whats the probelem in that.

Member
 
Join Date: May 2008
Posts: 118
#4: Feb 2 '09

re: Problem in mail sending


Quote:

Originally Posted by dlite922 View Post

Does your smtp server require a username and password or authentication?


Dan


No.I put the option as Anonymous access.So i didn't set the username and password.

Please give the suggestion.
Reply