php mail on windows server

Discussion in 'PHP' started by kichus, Apr 18, 2007.

  1. #1
    Hi

    I have a simple mail function which works perfectly on a linux server, but not on a windows.
    <?php
    $to      = 'info@servername.com';
    $subject = 'the subject';
    $message = 'hello';
    
    $headers = 'From: [email]welcome@servername.com[/email]' . "\r\n" .
        'Reply-To: [email]welcome@servername.com[/email]' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
    
    mail($to, $subject, $message, $headers);
    ?> 
    PHP:
    can anyone help me to work the mail function on windows.

    Thanks
     
    kichus, Apr 18, 2007 IP
  2. Rasczak

    Rasczak Peon

    Messages:
    131
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hey, i'm not very skilled with this function, but i'm using it quite often...

    try replacing
    [email]email[/email]
    PHP:
    with <email>...

    pls let me know...



     
    Rasczak, Apr 18, 2007 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Mail is a unix script/program.

    It won't work on IIS.

    Peace,
     
    Barti1987, Apr 18, 2007 IP
  4. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is there a similar program that will work on IIS.

    Thanks
     
    kichus, Apr 18, 2007 IP
  5. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #5
    mail function should work on IIS(or windows) too...if and only if you have an SMTP server ready to handle your outgoing mail request.
     
    agnivo007, Apr 18, 2007 IP
  6. firmaterra

    firmaterra Peon

    Messages:
    756
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #6
    check your mail server log to see if the mail is being rejected. If there's no sign of your mail then at least you know the problem lies with your php code. Very often your smpt settings require outbound authentication and you may not be passing this in your script.
     
    firmaterra, Apr 21, 2007 IP
  7. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i updtaed php.ini but still not able to send mails.

    The server is a dedicated one.
     
    kichus, Apr 22, 2007 IP
  8. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I was able to get PHP mail to work under Windows by editing the following lines in the php.ini file and then restarting Apache:

    SMTP = mail.my_isp_smtp_server.com
    smtp_port = 25
     
    clancey, Apr 22, 2007 IP
  9. mayuroak

    mayuroak Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    U might have to configure SMTP on windows server. So that this mail function will start working on windows as well.

    Mayur.
     
    mayuroak, Apr 22, 2007 IP
  10. kernes

    kernes Peon

    Messages:
    184
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #10
    you must install apache server on you windows which one you use and then you install mail server system.
     
    kernes, Apr 23, 2007 IP
  11. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    configured smtp server and edited php.ini .... it did the trick... thanks everyone
     
    kichus, May 10, 2007 IP
  12. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #12
    You may use the SMTP authentication to send mail through PHP script. Some hosting providers do not allow to send mail through script with out SMTP authentication. You may use the phpmailer script to send mail through PHP script. For more info on this go to http://phpmailer.sourceforge.net/

    Kailash
     
    kailash, Aug 23, 2007 IP