tags:

views:

52

answers:

3

Hello guys,

Here i am new to PHP, i want to send the mail and my application is running on go daddy sahre hosting so please tell me hows can i achieve it . thanks to all.

i got the response from you guys and i tried but there is some problem . this is my code ..

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Mail</title>
</head>

<body>
<?php
        if( isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['msg']) )
        {
            $to = $_POST['email'];
            $subject = $_POST['subject'];
            $msg = $_POST['msg'];
            $from = "[email protected]";
            $headers = "From: $from";
            mail($to,$subject,$msg,$headers);
            echo "Mail Send";
        }

 ?>
 <form action="sendMail.php" method="post">

 <div>
 <table style="width:100%;">
 <tr>
 <td>Email:</td>
 <td><input type="text" name="email" /></td>
 <td>Subject:</td>
 <td><input type="text" name="subject" /></td>
 </tr>
  <tr>
 <td>Message</td>
 <td><input type="text" name="msg" /></td>
 <td colspan="2"> <input type="submit" value="Send Mail" /></td>

 </tr>
 </table>
 </div>
 </form>
</body>
</html>

And after running this page i got the error "Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5676400\html\myPhp\temp\admin\sendMail.php on line 17"

+2  A: 

The PHP mail() Function

Basic Example:

<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
NAVEED
Thanks to reply , i tried your code but i got the error message, here i am editing the my question , i am putting my code and also the error message please see what is the problem in that. thanks once again.
Abhisheks.net
what's the error message?
silent
I think you have to provide some SMTP settings. I posted very basic example. You have to provide some more information according to your server settings. Look at these: **1.** http://www.phpbuilder.com/board/showthread.php?t=10367822 **2.** http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm **3.** http://w3schools.invisionzone.com/index.php?showtopic=28584
NAVEED
+1  A: 

Naveed's answer is all that is required for sending a basic email.

For reference:

PHP's Mail function - http://php.net/manual/en/function.mail.php

Commonly used classes providing additional functionality:

PHPMailer - http://phpmailer.worxware.com/

Zend_Mail - http://framework.zend.com/manual/en/zend.mail.html

Alex Osborn
A: 

Beware that while the PHP mail() function is pretty simple and convenient to use, the computer OS must be able to send mail by itself.

You have to check the return value of mail() (boolean, true if mail was accepted for delivery).

  $result = mail( ... );

If the $result variable is false, you have to check your computer mail configuration/implementation.

If it is true, and the mail is not sent, you have to check the computer mail logs.

ring0