SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie in php mail,Help needed

    Hi All,
    I am learning a php mail.now i have written a script with help of php mail from php.net.
    the script is:
    <?php
    $to=empty($_POST['T1'])?'':$_POST['T1'];
    //$from=webmaster@{$_SERVER['SERVER_NAME'];
    $subject=empty($_POST['T3'])?'':$_POST['T3'];
    $message=empty($_POST['S1'])?'':$_POST['S1'];
    $submit=empty($_POST['B1'])?'':$_POST['B1'];
    if ($submit="Send") {
    mail($to, $subject, $message,
    "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    "Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    "X-Mailer: PHP/" . phpversion());
    mail($to,$subject,$message);

    }
    else {
    Print "It is not possible to you.";
    }
    ?>
    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    </head>

    <body>

    <form method="POST" action="">

    <p>To<input type="text" name="T1" size="20"></p>
    <p>From<input type="text" name="T2" size="20"></p>
    <p>Subject<input type="text" name="T3" size="20"></p>
    <p>Message<textarea rows="2" name="S1" cols="20"></textarea></p>
    <p><input type="submit" value="Send" name="B1"></p>
    </form>

    </body>

    </html>

    but the error shown that
    Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for ujjwal_29@rediffmail.com in d:\Inetpub\wwwroot\mail.php on line 11

    Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for ujjwal_29@rediffmail.com in d:\Inetpub\wwwroot\mail.php on line 12

    Plz help me where i am wrong and correct my script.

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    You may not have the mail function set up correctly in PHP.INI. Also you actually call the mail function twice

    PHP Code:
     
    mail
    ($to$subject$message,
    "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    "Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    "X-Mailer: PHP/" phpversion()); 
    And here

    PHP Code:
     
    mail
    ($to,$subject,$message); 
    Thats why you get 2 errors instead of just one. Do you have access to the PHP.INI file?

    Mark

  3. #3
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I can access my php.ini.
    now i have changed it in this way :
    [mail function]
    ; For Win32 only.
    SMTP = smtp.my.server.net ; for Win32 only
    smtp_port = 25
    sendmail_from= santanu@featuredhost.com ; for Win32 only

    ; For Win32 only.
    ;sendmail_from = smtp.ujjwal.featuredhost.net

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ;sendmail_path =

    ; Force the addition of the specified parameters to be passed as extra parameters
    ; to the sendmail binary. These parameters will always replace the value of
    ; the 5th parameter to mail(), even in safe mode.
    ;mail.force_extra_parameters =
    now I have changed something in my php.ini
    Now the error is:
    Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.my.server.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in d:\Inetpub\wwwroot\mail.php on line 11

    Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.my.server.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in d:\Inetpub\wwwroot\mail.php on line 12

    plz help me what shoul be the value in php.ini mail fuction in standalone as well as Internet.
    thanks for u'r guide

  4. #4
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to change

    Code:
     
    SMTP = smtp.my.server.net ; for Win32 only
    That line to the address of your smpt server? Do you know the address, if not try looking on your email providers site. Unless you want to set up an SMTP server locally.

    Mark

  5. #5
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now again i have changed php.ini file.
    the change part is
    [mail function]
    ; For Win32 only.
    SMTP = mail.featuredhost.com ; for Win32 only
    smtp_port = 25
    sendmail_from= santanu@featuredhost.com ; for Win32 only

    ; For Win32 only.
    ;sendmail_from = santanu@featuredhost.com
    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ;sendmail_path =

    ; Force the addition of the specified parameters to be passed as extra parameters
    ; to the sendmail binary. These parameters will always replace the value of
    ; the 5th parameter to mail(), even in safe mode.
    ;mail.force_extra_parameters =
    Now the error is:
    Warning: mail() [function.mail]: SMTP server response: 553 sorry, that domain isn't allowed to be relayed thru this MTA (#5.7.1) in d:\Inetpub\wwwroot\mail.php on line 16
    what is the MTA?why this warnning show here?What should be the correct script?
    I have shown my script once again
    <?php
    $to=empty($_POST['T1'])?'':$_POST['T1'];
    //$from=webmaster@{$_SERVER['SERVER_NAME'];
    $subject=empty($_POST['T3'])?'':$_POST['T3'];
    $message=empty($_POST['S1'])?'':$_POST['S1'];
    $submit=empty($_POST['B1'])?'':$_POST['B1'];
    if ($submit="Send") {
    //mail($to, $subject, $message,
    //"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    //"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
    // "X-Mailer: PHP/" . phpversion());
    //mail($to,$subject,$message);
    //mail($to, "$subject", $message, "FROM: santanu@featuredhost.com");
    mail($to, $subject, $message,
    "From: webmaster@{$_SERVER['SERVER_NAME']}" .
    "Reply-To: webmaster@{$_SERVER['SERVER_NAME']}");


    }
    else {
    Print "It is not possible to you.";
    }
    ?>

  6. #6
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you dont haver permission to use that SMTP server eith your domain. try mail.yourserver.com

    EDIT

    Oh wait, you have, Think your SMTP server has some odd settings. Sorry
    New Design - PHP Slowly flowing in!

    Infizi Studio's


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •