Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with mail function

    hi,

    i run the below code i got the below error when i run in my local system.And i placed same program in website it works fine.plz tell that what's the mistake in that.
    PHP Code:
    $to ="aa@gmail.com";
    $subject "Site Registration Confirmation";
    $message '<html>
    <head>
    <title>Site Registration Confirmation</title>
    </head>
    <body style=font-family:verdana, arial; font-size: .8em;>
    You filled out a registration form 
    <br/><br/>
    </body>
    </html>'
    ;
    //headers type to sent the mail
    $headers "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSMail-Priority: Normal\n";
    // from address is take what ever we want
    $from "me@example.com";
    $headers .= "From: $from";
    //mail function
    mail($to,$subject,$message,$headers); 
    error :Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in e:\project\DataMining\mailcheck.php on line 22

  • #2
    New Coder
    Join Date
    Jul 2008
    Posts
    99
    Thanks
    0
    Thanked 4 Times in 4 Posts
    try adding this to the top of your php file..

    Code:
    ini_set ("sendmail_from","webmaster@yourdomain.com");

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    99
    Thanks
    0
    Thanked 4 Times in 4 Posts
    when i run in my local system
    oops... just read that, you'll need to set a SMTP server (and port) in your php.ini file or like this:

    Code:
    ini_set ("SMTP","smtp.yourmailserver.com");
    ini_set("SMTP_PORT","25");
    BTW, your code should just work fine once you upload it to the server...

  • #4
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Warning: mail(): Failed to connect to mailserver at "me@example.com " port 25

    hi,

    i use the below code .but in that i got the error

    And my php.ini contains

    [mail function]
    ; For Win32 only.
    SMTP = localhost ; for Win32 only
    sendmail_from= me@localhost.com ; for Win32 only
    SMTP_PORT=25;

    ; For Win32 only.
    sendmail_from = me@example.com
    SMTP_PORT=25


    plz tell that whats the mistake.

    PHP Code:

    <?php
    ini_set 
    ("SMTP","smtp.yourmailserver.com");
    ini_set("SMTP_PORT","25");
     
    $to ="sravanik@eminosoft.com";
    $subject "Site Registration Confirmation";
    $message '<html>
    <head>
    <title>Site Registration Confirmation</title>
    </head>
    <body style=font-family:verdana, arial; font-size: .8em;>
    You filled out a registration form 
    <br/><br/>
    </body>
    </html>'
    ;
    //headers type to sent the mail
    $headers "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSMail-Priority: Normal\n";
    // from address is take what ever we want
    $from "me@example.com";
    $headers .= "From: $from";
    //mail function
    mail($to,$subject,$message,$headers);
    ?>
    error :

    Warning: mail(): Failed to connect to mailserver at "me@example.com " port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\Facebook\mailcheck.php on line 24

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    99
    Thanks
    0
    Thanked 4 Times in 4 Posts
    swethak, you need an actual mail server

    if you are planning to have your own web server, you could ask your ISP for your SMTP server, and you have to put it where it says "smtp.yourmailserver.com", that was just an example.


  •  

    Posting Permissions

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