Mail through php code not working

nacindia

Registered
Oct 4, 2009
1
0
51
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="[email protected]";
$to="[email protected]";
$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
 

thewebhosting

Well-Known Member
May 9, 2008
1,199
1
68
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.
 

juliandsouza

Registered
Oct 7, 2009
1
0
51
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.
 

thewebhosting

Well-Known Member
May 9, 2008
1,199
1
68
If the mail() is disabled on your server then you can use the phpmailer() to send the mail using the SMTP authentication script.
 

whwrobert

Active Member
Aug 21, 2009
26
0
51
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.