Jump to content


Photo

[HELP FOR A NEWBIE] Mail function


  • Please log in to reply
3 replies to this topic

#1 sriindira

sriindira
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 October 2006 - 05:02 PM

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...l4/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...l4/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 :(


#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 18 October 2006 - 05:13 PM

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!

#3 sriindira

sriindira
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 October 2006 - 05:31 PM

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


#4 sriindira

sriindira
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 October 2006 - 05:35 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users