Jump to content

Archived

This topic is now archived and is closed to further replies.

sriindira

[HELP FOR A NEWBIE] Mail function

Recommended Posts

Iam a newbie to Php and after searching a lot in google i learnt abt the mail() function in PHP and decided to use it this is the sample file code iam using

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
</head>

<body>
<?php
ini_set("sendmail_from", "info@mydomainname.org");

$to = "somename@domain.com";

$subject = "This is an Email";

$body = "This is the email body,";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //This is for HTM Format
$headers .= 'To:  ME<'.$_to.'>,' . "\r\n";
$headers .= 'From: Name<info@mydomainname.org>' . "\r\n";

if(mail($to, $subject, $body, $headers))
{
echo "Mail should have sent";
}else
{
echo "There must have been an error";
}

?>
</body>
</html>



However iam not able to get any mail . I also used this code to check if php was installed and it was installed


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
</head>

<body>
<?php
phpinfo();
?>
</body>
</html>


I saw the SMTP was pointing to Localhost so decided to change it to what i use in my OE ( though i dont know if we shld use that )

i used ini_set("SMTP", "mail.domainame.net");

in my initial line. Even then it doesnt send any mail. Since i use free host they dont provide me with any techical support.

Could someone help me :(

Share this post


Link to post
Share on other sites
Do you have to use a password when using OE, if you do, then the mail() will not work as it does not support any kind of AUTH!


me!

Share this post


Link to post
Share on other sites
Hi it doesnt need any authorization

however i tried the same from someother hosting which i have it sends mail but sends it as

cgi-mailer@kundenserver.de in this name

I dont knowwhy

Also when i use ftp i dont see any kind of CGI or PHP folders in both my ftp folders the first host doesnt send mail though it gives mail should have sent in the echo command and the other sends mailbut in different name as

cgi-mailer@kundenserver.de

I dont know whats the mistake

Share this post


Link to post
Share on other sites
Also i checked the server API in the phpversion()

FOr the host which sends mail it is given as CGI

For the host which doesnt send mail it gives apache

Since i dont know much about PHP can you tell me how shld i send mail for an apache server basically

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.