PHP  
downloads | documentation | faq | getting help | | php.net sites | links 
search for in the  
previousldap_unbindezmlm_hashnext
Last updated: Tue, 11 Jun 2002
view this page in Printer friendly version | English | Brazilian Portuguese | Czech | Dutch | Finnish | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Turkish

L. Email

mail() envoie du courrier �l�ctronique.

Directive de configuration du courrier �l�ctronique

SMTP string

Nom de serveur ou adresse IP du serveur SMTP que PHP sous Windows doit utiliser pour envoyer le mail avec la fonction mail().

sendmail_from string

Ent�te MIME "From:" qui doit �tre utilis� dans les mail, pour PHP sous Windows.

sendmail_path string

Localisation du programme sendmail (g�n�ralement /usr/sbin/sendmail ou /usr/lib/sendmail). La commande configure effectue une recherche automatique plut�t efficace pour vous, et choisit une des valeurs par d�faut. Si cette recherche �choue, vous pouvez indiquer les informations ici.

Les syst�mes qui n'utilisentp as sendmail doivent utiliser cette directive pour indiquer le programme de mail de remplacement. Par exemple, pour , vous pouvez utiliser la valeur suivante : /var/qmail/bin/sendmail.

Table des mati�res
ezmlm_hash -- Calcule la valeur de hash demand�e par EZMLM
mail -- Envoi de mail
User Contributed Notes
Email
add a note about notes
10-Nov-2001 08:35
For Windows users, you can likely set the SMTP directive in the php.ini
configuration file to your isp's SMTP mail server - the same as you use
for outgoing mail in your email client (Eudora, Outlook, etc.) . However,
check with your ISP before doing this!

eg
SMTP = mail.your_isp.com


31-Jan-2002 02:26

the 'sendmail_from' string is the default 'from' address supplied with any
outgoing mail if no other 'from' address has been supplied in the header
section of the mail() function. In other words, setting the 'from' address
in the mail() function overrides this setting.

19-Feb-2002 12:23
After guessing about an hour I found out that for my qmail installation
only the following php.ini setting works:

sendmail_path =/var/qmail/bin/qmail-inject

Woutjan Branderhorst.


22-Feb-2002 11:03

Check out Zend.com's code gallery under EMAIL, look for SMTP.

with the new class you can specify different hosts (with respective l/p)
anytime you wish.

good for guys who hasn't got the mail() enabled (i think) but can at least
open sockets.

again, i'm green at this, might be incorrect.


03-Apr-2002 04:58

Hi there,
here is a little snippet that can be used in your mail script in order to
check if the mail was really sent from the domain the message originated
from:

// array for allowed domains (lower case please)
$referers = array('php.net', 'www.php.net', 'us2.php.net');

// add upper case referrers
$size = sizeof($referers);
for($i = 0; $i < $size; $i++){
  $referers[] = strtoupper($referers[$i]);
}

// check referers
for($i = 0; $i < sizeof($referers); $i++){
  if(substr($HTTP_SERVER_VARS['HTTP_REFERER'], 7, strlen($referers[$i]))
== $referers[$i]){
    $bad_referer = FALSE;
    break;
  }
  else{
    $bad_referer = TRUE;
  }
}
if($bad_referer){
  header('Location: );
  exit;
}

I added the upper case domains, since once in a while surfers tend to
write in all-caps.

Hope that helps someone :-)

DrTebi


05-Apr-2002 01:28

Linux
Known situation mail() not work, but why ???

Try send a simple mail from shell
root@alpha:~# sendmail [email protected]
strange error ???

collect: Cannot write ./dfg35A7vav022304 (bfcommit, uid=XXX, gid=XXX):
Permission denied

queueup: cannot create queue temp file ./tfg35A7vav022304, uid=XXX:
Permission denied

Don't mess with permissons on /var/spool
 /var/mail /var/spool/mqueue
Just set them follow the instructions from sendmail readme
It seems that when sendmail runs not like a daemon ( without -bd or -bD
options ) it doesn't use corect QueueDirectory from /etc/mail/sendmail.cf

The solution is

set this line in php.ini
;For Unix only.You may supply arguments as well (default:'sendmail -t
-i').

sendmail_path="/usr/sbin/sendmail -t -i
-OQueueDirectory=/var/spool/mqueue/"

That's all. mail() now work fine :)))
Hope this will save up somebody's time, because i spent a lot of hours in
digging and tearing my hair (and my mother will colapse if she hear what a
words i use :)))

12-Apr-2002 02:35
As noted above sendmail_from is only used on MS Windows, to change the
default sender on unix you must add -f to sendmail_path. For example in a
<VirtualHost> directive:
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f
[email protected]"

would set the default return-path for mail from that virtual host.


20-May-2002 08:21

Dear all,

Setting up a system which will ask a new member to confirm he asked for it
by mailing him I experienced a problem. If a new member fills in a Hotmail
e-mailaddress he will receive my mail in his Junk Mail directory.

Many tips I found where telling te configure the php.ini on my server but
that is not enough. I use Apache on a Win32 so some things will be
different
for you Linux people but the problems I experienced do not have anything
to
do with that I believe.
But, configure your php.ini setting the mail functions, for Win32:

SMTP = mail.yourisp.com
sendmail_from = [email protected]

Now the most important.
When using mail() you should insert headers, and not just a few!!!
I give you an example I'm using.
Very important is also to include the ' To: ' header. I forgot this and
when
I put it in my code Hotmail didn't refuse my e-mails anymore. Only when
people have there Junk Mail listed as "Exclusive". But when
configured
"High" it will go ok.

Here the example:

$myname = "Me Myself";
$myemail = "[email protected]";

$contactname = "Mister Contact";
$contactemail = "[email protected]";

$message = "hello from happy me";
$subject = "A mail not refused by Hotmail";

$headers. = "MIME-Version: 1.0\r\n";
$headers. = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers. = "From: ".$myname."
<".$myemail.">\r\n";
$headers. = "To: ".$contactname."
<".$contactemail.">\r\n";
$headers. = "Reply-To: ".$myname."
<$myreplyemail>\r\n";
$headers. = "X-Priority: 1\r\n";
$headers. = "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";

mail($contactemail, $subject, $message, $headers);

I hope this helped someone.

Godfried van Loo
The Netherlands


26-May-2002 01:30

mail will NOT work if your system doesn't have
a /bin/sh (like in chroots...)

just take some time to figure it out ;)

29-May-2002 12:15
I use qmail, and have found that mail() will return TRUE even if there is
no valid email address in the To parameter. If you're having problems
getting mail() to work with qmail, double-check that the output from your
script produces a valid email message before looking further!


03-Jun-2002 03:11

i have noticed that the mail() doesnt work if you define some headers in a
variable ($headers) and also within the mail( ..here..  ). this causes a
conflict for some reason
example...

$headers = "MIME/TYPE blah blah blah";
$headers = "Cc: [email protected]";

mail("$headers", "From: [email protected]");

i hope this helps


03-Jun-2002 03:12

i have noticed that the mail() doesnt work if you define some headers in a
variable ($headers) and also within the mail( ..here..  ). this causes a
conflict for some reason
example...

$headers = "MIME/TYPE blah blah blah";
$headers = "Cc: [email protected]";

mail("$headers", "From: [email protected]");

i hope this helps


04-Jun-2002 01:03

Hi!

I'm using this:

mail($friend_email, "A friend wishes you to see this!",
"$message\n\nURL: $url\n\nYour friend, $you_name\n<a
href=\">$you_email</a>",
"From: $you_email");

I want to get a linked email adress of the $you_email adress. Since this
is not html, I know this is not correct. Do I need to use $headers ? or
can I send the message as html?

What do you recommend me to do?


06-Jun-2002 02:50

use these headers to send in html form

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


10-Jun-2002 08:40

Hi..
I'm using this
mail($to, $subject, $message, $headers);
when I run the program the following message occure
Warning: Failed to Connect in C:\apache\htdocs\mail\mail2.php 
please tell me what is the problem?
what should I do?


12-Jun-2002 03:07

If you have downloaded an email via POP connection, ex.:
$complete_email ="
Date: Wed, 20 Jun 2001 20:18:47 -0400
From: "Sergio Paternoster" <[email protected]>
To: "My Users" <[email protected]>
Subject: Hello from Sergio!
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello from Sergio!
";
and want to forward it to another email address, just change the To: field
into the encoded downloaded email and then use

mail("", "", "",$To_changed_complete_email);


26-Jun-2002 02:08

If some of your mails cannot be received by some people, you might have the
following problem: 

Some mailservers block messages with more than 1024 Characters in a single
line. 

Solution: just add a simple linebreak (\n) after the last space before
each character 1024

You could possibly use wordwrap() for this...


27-Jun-2002 09:53

having a little problem with the mail function. trying to generate several
emails to addresses submitted by a user and i need to tell if any of these
emails get returned as undeliverable. they do not, however get returned to
the "reply to" address nor the "from" address. where
would the returned message get sent?


28-Jun-2002 05:15

i don't understand this error :

Warning: Server Error in
C:\Inetpub\cris\theatre-contemporain\tintasfrescas
\news\news.php3 on line 81

line81 :
if (mail($to, $subject, $body, $header))
{
$mesg = $phrase5;
}
else
{
$mesg = $phrase12;
}

What's the problem ??

Please note that my server is running under windows 2000.

Thanks a lot


01-Jul-2002 03:12

Hey, can anyone tell me how to set the path to sendmail? I'm running
Indigomail ( sendmail for windows ) and I got it to send mail with perl
... I'm just unfamiliar with the syntax for the php mail() function ...
Here's what i have:

    $sendmail = "D:\\inetpub\\scripts\\sendmail.exe";
    $To = "[email protected]";

    if (mail($To, "Tech Maintenance Request from $name",
"Tech Maitenance Request\n\n $name $room - $building:\n\n
Description\:\n $problem \n", "From: $email",
"sendmail_path: $sendmail")) {
    print "Could not complete your request,
<b>$sendmail</b>";

    } else {

    print "The request was successfully mailed to $To";

    }


03-Jul-2002 01:06

hello... I want to use the mail() funtion, but somehow my code didn't work.

I have my ISP is Directv with SMTP : smtp.directvinternet.com

what do I need to do with the above SMTP in order to get my mail()
function to work ? I am using Window 2K server.

I already try to reconfigure my php.ini to:

smtp: smtp.directvinternet.com

What else do I need.  I am a newbie.

Thanks!

add a note about notes
previousldap_unbindezmlm_hashnext
Last updated: Tue, 11 Jun 2002
show source | credits | stats | mirror sites:  
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Mon Jul 8 08:17:45 2002 CEST