Jump to content

[HELP FOR A NEWBIE] Mail function


sriindira

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 :(
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.