PHP Doku:: Mail - book.mail.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzE-Mail-relevante ErweiterungenMail

Ein Service von Reinhard Neidl - Webprogrammierung.

E-Mail-relevante Erweiterungen

<<imap_utf8

Einführung>>


UnterSeiten:

Mail


8 BenutzerBeiträge:
- Beiträge aktualisieren...
Carlos
10.01.2011 16:46
If you use the function utf8_decode() for the subject variable you can receive text messages readables in utf-8.
pouletfou at gmail dot com
6.08.2009 19:39
I use this script to test webapps using mail with this little php script saved as /usr/sbin/sendmail :

#!/usr/bin/php
<?php
   
//====================================================
    // Program : Fake send mail
    // Author : pouletfou at gmail
    // Description : save this file as /usr/sbin/sendmail
    //  and you can test your PHP applications using mail
    //  by looking at the /tmp/fakesendmail.log files.
    //====================================================

   
define('LOGFILE','/tmp/fakesendmail.log');

   
$log = fopen (LOGFILE,'a+');

   
fwrite($log,"\n".implode(' ',$argv).
    
" called on : ".date('Y-m-d H:i:s')."\n");

   
fwrite($log,file_get_contents("php://stdin"));
   
fwrite($log,
"\n===========================================================\n");
   
fclose($log);

?>
Ashlin
15.04.2009 19:34
2 points have to be set :

<?php
ini_set
("SMTP","smtp.example.com" );
ini_set('sendmail_from', 'user@example.com');
?>

or set them in the php.ini file

By doing this, i have fixed definetly this problem :-)
burkestar at gmail dot com
6.11.2008 7:15
The workaround mentioned above only works with IIS 5 assuming you've configured the Virtual SMTP Server to accept relays. 

In IIS console, right-click SMTP Virtual Server and choose "Properties". On "Access" tab, click "Relay..." button and make sure "All except the list below" is selected.

Warning: This is just a quick fix which exposes a security risk because allowing your SMTP server to be a relay with anonymous access could make your computer susceptible to becoming a spam zombie.  You should properly add your computer's IP address to the list and choose "Only the list below" instead to lock it down.
podlom at gmail dot com
23.10.2008 15:24
If you are sending e-mails in non latin character add charset information.
For example:

<?php
// header for Russian encoding will be: windows-1251
$header = "From: Shkodenko V. Taras p0dl0m@gmail.com"\nContent-Type: text/plain; charset=\"windows-1251\"\nContent-Transfer-Encoding: 8bit";
?>
Jung-Ho
14.10.2008 22:42
What "Some Guy" stated is true (for my case at least).

I am running WinXP Pro, IIS5, PHP5.

To test PHP's mail function, I utilized the below code that "dev at realynospamspcweb dot nl" posted (the code that they stated worked for them without errors).

<?php

$Name
= "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>

This (the above code) did not work for me.

But after utilizing "Some Guy's" tip and making the below modification, it did.  Thank you "Some Guy".

<?php

$Name
= "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

ini_set('sendmail_from', 'me@domain.com'); //Suggested by "Some Guy"

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>

Now this code worked for me.

It might be of interest that I did not need to modify any of the default "php.ini" settings...

SMTP = localhost
smtp_port = 25
Some guy
1.09.2008 14:17
Under windows there is a bug in php/mail

See here: http://bugs.php.net/bug.php?id=28038

this results in you being unable to send 'From: Full Name <me@domain.com>'

Workaround is:

Set the following before calling the mail function:

ini_set('sendmail_from', 'me@domain.com);
dev at realynospamspcweb dot nl
22.08.2008 23:16
@Crusiatus Black
23-May-2008 05:00

Code below works without errors
<?php

$Name
= "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)