Problem occure in the mail() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sravani1
    Banned
    New Member
    • Mar 2008
    • 10

    Problem occure in the mail() function

    Hi,

    I run the following code error will occure. Plz tell that what mistake i have done
    [php]<?php
    // multiple recipients
    $to = 'sravani_409@ya hoo.com' . ', '; // note the comma
    $to .= 'jyothsna11_123 @yahoo.com';

    // subject
    $subject = 'Birthday Reminders for August';

    // message
    $message = '
    <html>
    <head>
    <title>Birthd ay Reminders for August</title>
    </head>
    <body>
    <p>Here are the birthdays upcoming in August!</p>
    <table>
    <tr>
    <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
    <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
    <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
    </table>
    </body>
    </html>
    ';
    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'To: Mary <vani@eminosoft .com>, Kelly <sravanik@emino soft.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <jyothsna11.123 @gmail.com>' . "\r\n";
    $headers .= 'Cc: soundarya_435@y ahoo.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@e xample.com' . "\r\n";
    // Mail it
    mail($to, $subject, $message, $headers);
    ?>[/php]
    error :Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\mai l1.php on line 43
    Last edited by ronverdonk; Mar 20 '08, 09:59 AM. Reason: code tags inserted!!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is the third and last warning.

    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future.

    MODERATOR
    Last edited by ronverdonk; Mar 20 '08, 10:00 AM. Reason: warning

    Comment

    • Ramu528
      New Member
      • Mar 2008
      • 18

      #3
      Originally posted by sravani1
      Hi,

      I run the following code error will occure. Plz tell that what mistake i have done
      [php]<?php
      // multiple recipients
      $to = 'sravani_409@ya hoo.com' . ', '; // note the comma
      $to .= 'jyothsna11_123 @yahoo.com';

      // subject
      $subject = 'Birthday Reminders for August';

      // message
      $message = '
      <html>
      <head>
      <title>Birthd ay Reminders for August</title>
      </head>
      <body>
      <p>Here are the birthdays upcoming in August!</p>
      <table>
      <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
      </tr>
      <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
      </tr>
      <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
      </tr>
      </table>
      </body>
      </html>
      ';
      // To send HTML mail, the Content-type header must be set
      $headers = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      // Additional headers
      $headers .= 'To: Mary <vani@eminosoft .com>, Kelly <sravanik@emino soft.com>' . "\r\n";
      $headers .= 'From: Birthday Reminder <jyothsna11.123 @gmail.com>' . "\r\n";
      $headers .= 'Cc: soundarya_435@y ahoo.com' . "\r\n";
      $headers .= 'Bcc: birthdaycheck@e xample.com' . "\r\n";
      // Mail it
      mail($to, $subject, $message, $headers);
      ?>[/php]
      error :Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\mai l1.php on line 43
      Hi Sravani,

      Its an SMTP error. contact ur system administrator to set the settings of your server which u r using. SMTP u have to set an default emailid too. Default IP has to be changed.
      All the Best,
      Ramu
      Hyderabad

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by Ramu528
        Hi Sravani,

        Its an SMTP error. contact ur system administrator to set the settings of your server which u r using. SMTP u have to set an default emailid too. Default IP has to be changed.
        All the Best,
        Ramu
        Hyderabad
        I think he is using his local windows machine, So System Administrator?

        @Original Poster
        Hi, just check your php.ini file for smtp settings. you have to use a real SMTP server IP/host and a port to send mails from your local machine. if you need more info on this please post back. thanks

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by ak1dnar
          I think he is using his local windows machine, So System Administrator?

          @Original Poster
          Hi, just check your php.ini file for smtp settings. you have to use a real SMTP server IP/host and a port to send mails from your local machine. if you need more info on this please post back. thanks
          Probably quicker and easier to show (only) the mail and SMTP settings in your PHP.INI file here.

          Ronald

          Comment

          Working...