How To Enable Mail() Function In Php

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

How To Enable Mail() Function In Php

itssami
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.

 

 

 


Reply

shadowx
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

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. enabled mail servers joomla - 3.02 hr back. (1)
  2. the mail() function disabled joomla - 5.21 hr back. (1)
  3. enabling mail function localhost - 6.82 hr back. (1)
  4. enabling mail function - 6.84 hr back. (1)
  5. how to enable php mail send - 6.91 hr back. (1)
  6. enable php mail to - 8.58 hr back. (3)
  7. how to enable mail() in php.ini - 9.60 hr back. (1)
  8. "mail function" javascript code - 12.27 hr back. (1)
  9. php enable mail - 12.91 hr back. (1)
  10. how to change php smtp server centos mail function limited - 13.83 hr back. (1)
  11. turn on php mail in php.ini file - 14.32 hr back. (1)
  12. php enable mail() - 15.10 hr back. (1)
  13. enabling php mail() - 16.30 hr back. (1)
  14. how to enable javascript for hotmail - 17.99 hr back. (2)
Similar Topics

Keywords : enable, mail, function, php

  1. A Question About Php Mail
    A question about how php send mail using which email account in SMTP s (1)
  2. PHP Function To Add Previous and Next Page Feature
    useful php function (5)
    CODE <?php function navigationbar($start_number = 0, $items_per_page = 50,
    $count) {    // Creates a navigation bar    $current_page =
    $_SERVER["PHP_SELF"];     if (($start_number < 0) ||
    (! is_numeric($start_number))) {         $start_number = 0;     }
        $navbar = "";     $prev_navbar = "";     $next_navbar =
    "";     if ($count > $items_per_page) {         $nav_count = 0;
            $pag....
  3. Endif function?
    (6)
    As you get noticed before, I am studying PHP in examples like using the tutorials as well as books
    itself. Through my readings, I get this function CODE <?php endif; ?> a lot of times.
    So, what do you mean by this function, and what does it do exactly?....
  4. Requirements For Mail()
    (2)
    I'm trying to use mail() function. What I have to do beforehand? I have XAMPP installed, is
    Mercury one of mail servers? If so, what I could do to use it?....
  5. Php Functions To Send Mail
    (9)
    Which other methods to send mail from a form? I just know mail function, like: mail(string to,
    string subject, string message) Has anyother?....
  6. Arrays Outside A Function
    Need to have arrays available to all functions. (3)
    I've got a bunch of arrays that i want to use for more then 1 function. when i declear the
    arrays outside a function i cant use it in a function. This code was originally written in
    javascript by another person but since I plan to use it and extend it with php I had to change it
    from javascript to php code. In the javascript code the arrays were decleared outside the functions
    with 'var arrayname' I read somewhere that declearing javascript variables with
    'var' gives it global access. Any ideas on how I can go about declearing 1 set of these
    arrays t....
  7. Prequirement For Mail()
    (1)
    I'm asking because I often see so many books told me to use mail() feely, but I don't really
    understand. Can we really use this without even have a mail server or anything related to that? Or
    even if we need something before using this function, can anyone tell me waht those are? Right now
    my website had not have this function yet, but I'm trying to, because it's necessary
    sometimes when I got another project.....
  8. How To Check If Fsockopen Function Is Enabled?
    (2)
    Hi, I have VPS (virtual private server) and I have access to php.ini file. Is there any script that
    will show that fsockopen function is enabled or where do I have to enable it? Searched google and
    here and couldn't find anything. Thanks! ....
  9. Php Explode Function Help
    (4)
    I am having trouble creating a script, all i want to achieve is to: 1. Select the variable from my
    mysql database, which is in a format of : id|id|id|id| and so on... 2. Split them into separate
    variables by using : $songexploded = explode("|",$ttyo ); 3. Then this is the bit I'm
    stuck on trying to create a while loop from the $songexploded variables. So(this might not be
    correct but you should get the idea).. CODE $x=1; while ($songexploded
    ==$result) echo $songexploded[$x].'<br>'; }....
  10. The Best Zip Function
    (1)
    hi my 6th code is very useful, you can zip your file by this: CODE <? class dZip{     var
    $filename;     var $overwrite;          var $zipSignature =
    "\x50\x4b\x03\x04"; // local file header signature     var
    $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
        var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir
    signature     var $files_count  = 0;     var $fh;          Function
    dZip($filename, $overwri....
  11. Mail() Clone
    A PHP mail() function clone (5)
    A lot of free web hosts have disabled the mail() function so you cannot send emails using PHP. Does
    anybody know of a script that makes a function "like" mail but is able to be installed in a web
    accessible directory and called included into another script and called like that? Or maybe you know
    how to make such a function? I just really need to find a way around the free hosts turning of the
    mail() function. I need to figure out a way to send emails.....
  12. [php](simple) Using Functions To Combine Values In A Form
    Really simple example on how to combine values with function (2)
    I just learned this simple method on how to use functions to combine two values from a form. First
    we create ourselves a simple POST form CODE <form method="POST"> Name:
    <input type="text" name="nickname"> Location: <input
    type="text" name="location"> <input type="submit"
    value="Input"> </form> Now we add this php to that same file CODE
    <?php $nick = $_POST['nickname']; $location =
    $_POST['location' ....
  13. [php] Header Function
    (2)
    Header function Greetings we are going to use the header() funtion to redirect start making a
    file called page.php at the top of the file add CODE <?php ?> Example 1 After
    CODE header('Location: http://www.trap17.com'); the LOCATION means
    where you want it to go. Example 2 you also can define a file that you want to redirect to After
    CODE header('Location: index.php'); Example 3 you also can add a timer to
    it /laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt=....
  14. Error With Joomla Template
    cant find function (1)
    Hello! I am working on my template in Dreamweaver and i am using joomla extensions for
    dreamweaver! When i start my page with joomla stand alone server(jsas) i get this errors on the
    bottom of the page! QUOTE Warning:
    mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
    file or directory in w:\www\Joomla\includes\frontend.php on line 66 Warning:
    mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
    file or directory in w:\www\Joomla�....
  15. The Extract() Function
    Something I just found out (6)
    The extract() function is used in PHP to take an array and split it up into variables. MySQL
    queries can be parsed this way. Below is an example. CODE $query =
    mysql_query("select username, password from users where uid=1"); $result =
    mysql_fetch_array($query, mysql_assoc); extract($result); print "Your
    username is : $username"; The extract() function works for ANY array, including
    $_POST, and $_GET. Makes processing form data a LOT easier /biggrin.gif"
    style="vertical-align:midd....
  16. How Good Is This Data Cleaning Function?
    (2)
    Hi all, this is my first function and as part of a script and i just want to know a couple of
    things. here is the code for the function: CODE <? function
    clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
    $murky_string = strip_tags($muddy_string); $clean_string =
    htmlentities($murky_string);      }; ?> So the first thing is how secure is
    it? the script this will be used in connects to a database and sends an email so it needs to stop
    SQL injections and any email ab....
  17. Explode Function Help
    need help from you programmers! (1)
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Hi I am robert I
    need some help with some php coding. I am stuck with a explode function. Here is the code:
    $username = $check ; $query="SELECT `buildings` FROM `authuser` WHERE
    `uname` = '$username'"; $result=mysql_query($query);
    $result=mysql_result($result,0);
    list($building1,$building2,$building3,$building4,$building5,$building6
    ,$building7,$building8,$building9,....
  18. Want To Send Mail But Smtp Disabled, Help Me!
    (7)
    heyy...I have a problem, I have an account in another hosting service, but the SMTP and sendmail
    was disabled for my account. and I want to send mail to all people who join my site (with php script
    to send that mail), so I can't send mail to them. for more information, my operating sistem is
    Linux and php version 4.4.1. I hear when drupal send e-mail without SMTP, is that true??? and can
    I send mail when I already installed Drupal in my hosting service???? Please give me solution,
    how can I send an e-mail when my sendmail and SMTP disabled!!!!....
  19. Wappymail_v1.50
    wap free mail/ email admin script :-) (15)
    Here is my new wap mail script. You can use it as a free email sending service or an email admin
    form (can set this option in config.php) its extremly simple to install and you will find full
    instructions in the zip file. Please feel free to comment, rate, or update this script :-)
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> ....
  20. Regexp Function Preg_match_all()
    preg_match_all() - Help me (0)
    Hi, I got a new problem which has caused me to go mad but no solution. preg_match_all() - is the
    problem. I have something like this: CODE [ol] [li]Test1[/li]
    [li]Test2[/li] [li]Test3[/li] [li]Test4[/li]
    [li]Test5[/li] [/ol] Some text.Some text.Some text. [ol]
    [li]Test1[/li] [ol] [li]Test1[/li]
    [li]Test2[/li] [li]Test3[/li] [li]Test4[/li]
    [li]Test5[/li] &....
  21. Bulk Mail
    How to do that (5)
    Hey , I have a problem . I wanted a script to send emails using PHP to more than 5000 email
    addresses for my software. But if you use the regular mail() function it will cause tremendous
    overload o the servers. I tried searching on the net but no use and i found some pre-built ones
    which are either copyrited or using PHP 5 only. But I want to make my own function to send Bulk
    Mails. If someone could give me a start I would be thankful. So does any one know how to send
    bulkmail. Also I needed to give an option of using SMTP servers if PHP mail is not supported on....
  22. Help With Mail And Attachments
    Help on mail attachments (4)
    Hi, can someone please give me an example of how to send a zip or other filetype as an attachment
    using the mail() command? Im also interested in sending to mail email address, for example i have a
    .txt file full of email addy's like: mail1@blah.net mail2@blah.net mail3@blah.net how can i send
    the file and or mail to all these addy's in one go? Mmm......
  23. Question About The Mail() Function
    (2)
    Hi, Is there any way of using the mail() function with an SMTP connection? Is there any way of
    sending messages let's say for example using an email of yahoo? Any help about this woul be very
    thankfull. Thanks in advance.....
  24. Include File.php?id=something
    using the include() function (13)
    Well, I am making a full CMS system for my site, and want to make the index.php file to include the
    view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
    'view.php?id=1' ?> This is the error I get: CODE Warning:
    main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
    in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
    main() [function.include]: Failed opening 'view.php?id=1' for inclusion
    (i....
  25. How To Use A Link To Call Function In Php?
    (8)
    The title says it all, really. How do you call a function using in PHP? I'm doing a project
    and I stumbled upon this problem. I don't want to use query string in the href part like
    since that would mess up the other part of my code. Can anyone pleae help me? I've pasted the
    code below. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Thanksh.
    CODE <?php   function display($x){ //coding goes here.   } ?>
    <html> <body> <p align="center"> <a href="what g....
  26. php header() function help needed
    automatic re-direct (4)
    hey ppl, u seem to have real gud knowledge about php, i just wanted a little help...i designed this
    website, but i want that if i click on certain page, it should open for some few seconds and then
    browser should automatically redirect me to some other page....i tried this with header() function
    but i couldnt do the wait n redirect part, ... so somebody plz help.... -thanx in advance!....
  27. Need Help With Php
    GET function with timer (2)
    I need some help on creating a timer that every thirty minutes, refreshes on a URL. I know how to
    get the page, but I have no idea how to create a timer that initiates it. Could someone point me on
    a helpful direction?....
  28. Question For The If And Echo Function
    (2)
    I'm not that good with PHP, and I tried this code: CODE if (
    $_SERVER['REQUEST_URI'] == ('/') )/*'/' is the
    domain root*/ { echo('<img src="{I_ONEURL}" border="0"
    alt="{T_SOMETHING}" />'); } else { echo('<img
    src="{I_ANOTHERURL}" border="0" alt="{T_SOMETHING}" />'); }
    However, it doesn't work. So, basically, I want that if the request is at the root (actually
    mysubdomain.domain.com), it will show {I_ONEURL....
  29. Form To Php Mail. Attachment
    (14)
    i know there are a few topics talk about attachment problem, but i want to know if anyone could show
    me a basic code for attaching files like pictures with the message. I made a html form, and
    redirect the information to my mail.php file to process the information and send it to my email. I
    want to know what do i have to do to attach files like pictures. I tried to search on google, and
    the codes are so complicated (i'm an amateur at this). Would it be possilbe if you could show me
    the code and explain to me what it does and how i could customize it to fit my needs?....
  30. Getting List Of Directories And Files Using Php
    PHP Function for Directory and File List (6)
    is there a php function that lists the content of some folder.... example: /New folder new.txt
    left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
    style='vertical-align:middle' alt='rolleyes.gif' /> ....

    1. Looking for enable, mail, function, php

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for enable, mail, function, php

*MORE FROM TRAP17.COM*
advertisement



How To Enable Mail() Function In Php



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE