The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mail through php code not working

Discussion in 'E-mail Discussions' started by nacindia, Oct 4, 2009.

  1. nacindia

    nacindia Registered

    Joined:
    Oct 4, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    I am using a site where I collect informations from my members using the mail.
    It was working fine before, but suddenly its stop working I dont know why.

    here is the code sample

    test.html
    <html>
    <head>
    </head>
    <body>
    <form method="post" action="sendmailfeedback1.php">
    <input type="text" name="textFullName">
    <input type="submit" value="Submit" name="Submit">
    </form>
    </body>
    </html>

    sendmailfeedback1.php
    <?php
    $from="info@nacindia.in";
    $to="sanjitims@gmail.com";
    $subject="Feedback Information";
    $msg="/********************************************/";
    mail($to,$subject,$msg,"From:$from");
    ?>
    <body>
    Thank u ... <a href="index.html">click here</a> to go to home page
    </body>

    Do I need to change any mail setting on cpanel.Please help me out. I am in a big trouble
    Thanks
     
  2. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    Is there any error message are you receiving? You can also check the email logs for the exact error message from the /var/log/exim_mainlog.
     
  3. linux7802

    linux7802 Well-Known Member

    Joined:
    Dec 14, 2007
    Messages:
    232
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Solution

    You need to check it with your hosting provider because php mail function need to be enable on your server to send an E-mail by using php script.Get more information on phpmail function here
     
  4. juliandsouza

    juliandsouza Registered

    Joined:
    Oct 7, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    If you're searching for a way to send via SMTP, then I guess you don't mean the mail() function as you would find tonnes of information on that.

    There's an alternative way, using PHP and sockets to connect to the SMTP server and send the commands that are requested by the SMTP server, the problem however is that most SMTP servers are set up to not allow RELAYing of messages from outside without SMTP authentification that you are actually an allowed user to use that SMTP server, reason being many SPAM mailers could use these servers to distribute their mail if they were not secured against it.

    If you want to find ideas, look for SMTP via Telnet methods, and then learn PHP sockets to do the exact same thing, as the method is just the same, except you're using PHP to do what you would do in Telnet.

    You will probably also need to read the RFC on SMTP so you can understand how verification and authentification is done, as well as limitations on it.
     
  5. saninfosys.com

    Joined:
    Oct 4, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Contact your hosting provider for php mail () function is enable or not. It may be disable due to security reason. If it is disable, ask for alternate to send mail via php script.
     
  6. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    If the mail() is disabled on your server then you can use the phpmailer() to send the mail using the SMTP authentication script.
     
  7. whwrobert

    whwrobert Active Member

    Joined:
    Aug 21, 2009
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Hello,

    The script you are using will use the nobody user of the server. The from and to field value specified in script will be shown in the mail when received. But the user used to send the mail will be nobody. So please check with your host that are they allowing mails to be send using nobody as I think they must have disabled nobody user on server.
     
Loading...

Share This Page