Re: mail function



Bent Stigsen wrote:
maya wrote:


I'm learning how to send mail with php...

only thing that mystifies me a bit is I can't get NAME of sender to
appear in e-mail INBOX under "from"... I only see e-mail address.. I'm
coming from Java, with Java you can set it up so whatever user puts
under "name" in the form you can grab and in e-mail INBOX under "from"
you see sender's name, not e-mail address.. I would like to be able to
do this with php.. I've looked at various tutorials, and so far can't
see how you can do this.. thank you..


If you use the mail-function, then there is an example of this in the
manual.
http://dk2.php.net/manual/en/function.mail.php

From "Example 4.":
$headers .= 'From: Birthday Reminder <birthday@xxxxxxxxxxx>' . "\r\n";


/Bent

thank you very much Bent...

I have:

$sendername = $_GET['name'];
$email = $_GET['email'];
$headers = 'From: $sendername <$email>' . "\r\n";

in email INBOX it says from $sendername (literally, does not print name...)

if I do

$headers .= 'From: $sendername <$email>' . "\r\n";

(add the '.' right before '=' like in example you cited..)
I get an error (undefined var in line where $header var is declared..)

I'm new to php.. and I would like to know, please, why is there a '.' sometimes before '='.. what is this for.. (it's not working for me right now, though..)

one thing that I find weird about php is how you can print vars inside or outside quotes... i.e., if I want to print a variable with some html I have to include in quotes not only the html (which makes sense), but also the variable, for example:

echo $x; // if I want to add some html here I have to do

echo "$x<br>"; // I think this is very weird..

I'm used to Java, in which you would do:

out.print(varName + "<br>"); // :)

thank you very much....






















.



Relevant Pages

  • Re: Recommendations for a web application framework?
    ... Yet I still see this duality wherein there's a Java class representing the form. ... you can not eliminate this duality if you want to use HTML templates and insert a value into a specific position in the template. ... To be perhaps a little clearer, what JSF does is ensure that the correspondence between identifiers and names in Java code and HTML content is one-way. ... Java may have a verbose syntax, but it's still much better than XML, especially with a decent IDE. ...
    (comp.lang.java.programmer)
  • Re: What is the learning curve for PHP?
    ... HTML properly either. ... Books become ... HTML is not a programming language at all -- it's a data format, ... but isn't militant about making you use it like Java is. ...
    (comp.lang.php)
  • Re: building a meta search engine
    ... java is perfectly suitable to design meta search engine. ... read the html page and match every content and fetch the url and again ... Are there any ready-made Java open-source packages that would deal ... - Does parsing HTML files seem feasible at all? ...
    (comp.lang.java.help)
  • Re: soooo many questions!
    ... takes to create a dropdown HTML menu in Java, ... as a string via the toString ...
    (comp.lang.java.beans)
  • MVC in JSP (was: template in servlet)
    ... JSP = viel HTML mit wenig Java ... ... HTML ins JSP, ... public void setUser(String user) { ...
    (de.comp.lang.java)