Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail thing won't work 2

Status
Not open for further replies.

krigbert

Programmer
Jun 2, 2005
95
NO
Very simple question. Should this work?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " lang="en"><head><title></title></head>
<body>
<?php
mail("my@mail.com","testing title","It's working");
?>
</body>
</html>

Just checking if there's anything I've missed. Because it's not working, and I've tested other php code on that server, and it does work.

illustration and webdesign
 
I can see nothing syntactically incorrect, if that's what you mean.

However, using PHP's mail() function can be complicated. If possible, we would need to know some things about your installation:

On what platform are you running PHP?
What do the mail settings look like in php.ini?



Want the best answers? Ask the best questions! TANSTAAFL!
 
when I use the mail function I have to send headers... Here's a quick example
Code:
$Subject = "Testing Title";
$Body = "It's Working";
$Headers = "From: Someone@mail.com";
mail("Me@mail.com", $Subject, $Body, $Headers);
Now your emial will be sent to Me@mail.com and will appear to come from Someone@mail.com This I think is the trick to make your mail command work
 
Sorry I forgot to add... about headers
Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)

They say they are optional but I've found my mail function won't work with out them (PHP Version 4.3.11) Also if you don't include a From Header it will show which server sent them mail, which means your user can not directly reply. the other item in Headers is for multi part emails i.e. Text and HTML emails in one email
 
Whether your installation needs to set headers or not is, to my experience, more dependent on your mail server than on PHP version.



Want the best answers? Ask the best questions! TANSTAAFL!
 
I just recently did a mail form and was restricted to using mail(), so it's still a little fresh in my mind. From what I remember the documentation said that you have to set the From header if it has not already been set in the php.ini file.
 
My web-host requires that I specify a valid "from-address" from my own domain. If I don't, it won't work.

This is, ofcourse, to prevent spamming so it makes sense to me :)

Just an other idea to try out...


Jakob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top