php-doc-en/reference/mbstring/functions/mb-send-mail.xml
Maciej Sobaczewski e41aab5eca Remove changelogs for PHP 4 - 3rd round
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@334621 c90b9560-bf6c-de11-be94-00142212c4b1
2014-08-27 17:46:13 +00:00

165 lines
5.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mb-send-mail" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mb_send_mail</refname>
<refpurpose>Send encoded mail</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>mb_send_mail</methodname>
<methodparam><type>string</type><parameter>to</parameter></methodparam>
<methodparam><type>string</type><parameter>subject</parameter></methodparam>
<methodparam><type>string</type><parameter>message</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>additional_headers</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>additional_parameter</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Sends email. Headers and messages are converted and encoded according
to the <function>mb_language</function> setting. It's a wrapper function
for <function>mail</function>, so see also <function>mail</function> for details.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>to</parameter></term>
<listitem>
<para>
The mail addresses being sent to. Multiple
recipients may be specified by putting a comma between each
address in <parameter>to</parameter>.
This parameter is not automatically encoded.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>subject</parameter></term>
<listitem>
<para>
The subject of the mail.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
The message of the mail.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>additional_headers</parameter> (optional)</term>
<listitem>
<para>
String to be inserted at the end of the email header.
</para>
<para>
This is typically used to add extra headers (From, Cc, and Bcc).
Multiple extra headers should be separated with a CRLF (\r\n).
Validate parameter not to be injected unwanted headers by attackers.
</para>
<note>
<para>
When sending mail, the mail <emphasis>must</emphasis> contain
a <literal>From</literal> header. This can be set with the
<parameter>additional_headers</parameter> parameter, or a default
can be set in &php.ini;.
</para>
<para>
Failing to do this will result in an error
message similar to <literal>Warning: mail(): "sendmail_from" not
set in php.ini or custom "From:" header missing</literal>.
The <literal>From</literal> header sets also
<literal>Return-Path</literal> under Windows.
</para>
</note>
<note>
<para>
If messages are not received, try using a LF (\n) only.
Some Unix mail transfer agents (most notably
<link xlink:href="&url.qmail;">qmail</link>) replace LF by CRLF
automatically (which leads to doubling CR if CRLF is used).
This should be a last resort, as it does not comply with
<link xlink:href="&url.rfc;2822">RFC 2822</link>.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>additional_parameter</parameter></term>
<listitem>
<para>
<parameter>additional_parameter</parameter> is a MTA command line
parameter. It is useful when setting the correct Return-Path
header when using sendmail.
</para>
<para>
This parameter is escaped by <function>escapeshellcmd</function> internally
to prevent command execution. <function>escapeshellcmd</function> prevents
command execution, but allows to add addtional parameters. For security reason,
this parameter should be validated.
</para>
<para>
Since <function>escapeshellcmd</function> is applied automatically, some characters
that are allowed as email addresses by internet RFCs cannot be used. Programs
that are required to use these characters <function>mail</function> cannot be used.
</para>
<para>
The user that the webserver runs as should be added as a trusted user to the
sendmail configuration to prevent a 'X-Warning' header from being added
to the message when the envelope sender (-f) is set using this method.
For sendmail users, this file is <filename>/etc/mail/trusted-users</filename>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mail</function></member>
<member><function>mb_encode_mimeheader</function></member>
<member><function>mb_language</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->