Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How To Enable Mail() Function In Php
itssami
post Apr 12 2006, 03:52 PM
Post #1


Super Member
*********

Group: Members
Posts: 258
Joined: 13-November 05
Member No.: 14,234



im just trying to send mail by using a very simple php function mail() but it is not working.the format is


CODE
$to = "email@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}




I think there is something wrong with php.ini setting..maybe something to do with SMTP settings.. i want to send email FROM either hotmail , gmail , or yahoo or any other web based email because i dont know my ISP smtp setting..so can anyone please help me , where to make change and what to make change ?

Notice from BuffaloHELP:
All codes must be used inside of CODE bbcode tag.
Go to the top of the page
 
+Quote Post
shadowx
post Apr 12 2006, 04:23 PM
Post #2


Look around, what do you see? Incorrect.
***********

Group: [HOSTED]
Posts: 1,120
Joined: 12-April 06
From: Essex, UK
Member No.: 21,719
myCENT:85.74



QUOTE(itssami @ Apr 12 2006, 04:52 PM) *

im just trying to send mail by using a very simple php function mail() but it is not working.the format is
$to = "email@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
I think there is something wrong with php.ini setting..maybe something to do with SMTP settings.. i want to send email FROM either hotmail , gmail , or yahoo or any other web based email because i dont know my ISP smtp setting..so can anyone please help me , where to make change and what to make change ?


I've used the mail function quite alot on external hosts and its worked fine. When i tried to run this script on my localhost i got an error saying i needed to configure my php.ini settings for the FROM address but im not confident with playing with .ini settings and such so i left that be.

If you want to send an email and have the FROM address be anything specific you an use the headers variable in the mail() function.

eg:
QUOTE

$headers = FROMaddress@whatever.com;
mail($to, $subject, $body, $headers);


now when the mail is received the from address will be FROMaddress@whatever.com. The only problem is if sending to a hotmail user, or possibly some other email accounts, but particularly in hotmail the email provider will notcie the diferene in domains, eg sending the email from subdomain.trap17.com but having the FROM address as me@host.com hotmail will notice the differences and alert the user that the sender cannot be verified. If however your website was me.myhost and the FROM address was notme@myhost there would be no problem. I hope that helped with changing the FROM address. Sorry I cant help much about the problem with it not working though.

NOTE: it seems by editing this line
QUOTE
; For Win32 only.
;sendmail_from = me@example.com

in your .ini file you can permanently set the FROM address without using the $headers method. smile.gif Although i suspect this will still have the problems with verifying the sender's ID.

EDIT: Is there an error display when you try to use the mail function that is outputted to the browser? if there is could you post it and maybe it will help someone to see whats going on. smile.gif

This post has been edited by shadowx: Apr 12 2006, 04:24 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Form To Php Mail. Attachment(14)
  3. How To Use A Link To Call Function In Php?(8)
  4. Include File.php?id=something(13)
  5. Help With Mail And Attachments(4)
  6. Bulk Mail(5)
  7. Regexp Function Preg_match_all()(0)
  8. Wappymail_v1.50(15)
  9. Want To Send Mail But Smtp Disabled, Help Me!(7)
  10. Explode Function Help(1)
  11. How Good Is This Data Cleaning Function?(2)
  12. The Extract() Function(6)
  13. Error With Joomla Template(1)
  14. [php] Header Function(2)
  15. [php](simple) Using Functions To Combine Values In A Form(2)
  1. Mail() Clone(5)
  2. The Best Zip Function(1)
  3. Php Explode Function Help(4)
  4. How To Check If Fsockopen Function Is Enabled?(2)
  5. Prequirement For Mail()(1)
  6. Arrays Outside A Function(3)
  7. Php Functions To Send Mail(9)
  8. Requirements For Mail()(2)
  9. Endif function?(6)
  10. PHP Function To Add Previous and Next Page Feature(5)
  11. A Question About Php Mail(1)
  12. Search Engine/ Function(0)
  13. How To Send Email From Local Wamp To Internet(0)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 06:16 PM