By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

Sending mails with Php

P: 22
Hi .this is punit .I am back with one question on php.
I want make mail option in my project .please tell me how i code for sending mail option in php.As i am new in php so please suggest me how i proceed.
Thanks & Regards.
Punit Shrivastava
Aug 8 '07 #1
Share this Question
Share on Google+
4 Replies


ak1dnar
Expert 100+
P: 1,584
Hi .this is punit .I am back with one question on php.
I want make mail option in my project .please tell me how i code for sending mail option in php.As i am new in php so please suggest me how i proceed.
Thanks & Regards.
Punit Shrivastava
I think there are lots of threads here, about php mail function.
Search Results

Additionally you may take a look at on php mail funtion
Aug 8 '07 #2

ak1dnar
Expert 100+
P: 1,584
Hope the current thread title makes good traffic on the thread rather than the Original:

Disscusion for sending mail
Aug 8 '07 #3

P: 22
Hi Ajaxrand,
Thanks for suggesting.I code for contact form like this:
for 1st form :
Expand|Select|Wrap|Line Numbers
  1. <table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
  2. <tr>
  3. <td><strong>Contact Form </strong></td>
  4. </tr>
  5. </table>
  6.  
  7. <table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
  8. <tr>
  9. <td><form name="form1" method="post" action="mailform.php">
  10. <table width="100%" border="0" cellspacing="1" cellpadding="3">
  11. <tr>
  12. <td width="16%">Subject</td>
  13. <td width="2%">:</td>
  14. <td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
  15. </tr>
  16. <tr>
  17. <td>Detail</td>
  18. <td>:</td>
  19. <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
  20. </tr>
  21. <tr>
  22. <td>Name</td>
  23. <td>:</td>
  24. <td><input name="name" type="text" id="name" size="50"></td>
  25. </tr>
  26. <tr>
  27. <td>Email</td>
  28. <td>:</td>
  29. <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
  30. </tr>
  31. <tr>
  32. <td>&nbsp;</td>
  33. <td>&nbsp;</td>
  34. <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
  35. </tr>
  36. </table>
  37. </form>
  38. </td>
  39. </tr>
  40. </table>
  41.  
And for 2nd form i code like this :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Contact subject
  3. $subject ="$subject"; 
  4. // Details
  5. $message="$detail"; 
  6.  
  7. // Mail of sender
  8. $mail_from="$customer_mail"; 
  9. // From 
  10. $header="from: $name <$mail_from>"; 
  11.  
  12. // Enter your email address
  13. $to ='YOU@YOURDOMAIN.COM'; 
  14.  
  15. $send_contact=mail($to,$subject,$message,$header);
  16.  
  17. // Check, if message sent to your email 
  18. // display message "We've recived your information"
  19. if($send_contact){
  20. echo "We've recived your contact information";
  21. }
  22. else {
  23. echo "ERROR";
  24. }
  25. ?>
  26.  
But its shows error As it disply :-
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for YOU@YOURDOMAIN.COM in C:\Uniform3_1_1s\www\abc\mailform.php on line 23
ERROR .
Please suggest me about code .As i am new in php so kindly give me suggestion regarding to code.

I think there are lots of threads here, about php mail function.
Search Results

Additionally you may take a look at on php mail funtion
Please use code tags [code=php] .........[ /code] - ajaxrand
Aug 8 '07 #4

ak1dnar
Expert 100+
P: 1,584
Nice work ! There is No problem with your html form. But there are few issues with php script.

Didn't you try to get the POSTed values to Variables
Expand|Select|Wrap|Line Numbers
  1. $your_variable_name = $_POST['html_form_element'];
I didn't see them on the script.

Then The Error says something Like this, Your SMTP server doesn't allow you to send the mails.

If you are trying this on a Local server Set up your SMTP server to send mails.
Aug 8 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.