Send Email from PHP
How to send email with php using mail and mb_send_mail ...
There is no php coding required when using
Arclab Web Form Builder.
The
following should illustrate how to send an email from php in general:
What the difference between php mail and mb_send_mail?
- mail is for single byte charsets (e.g. iso-charsets or us-ascii)
- mb_send_mail is for multi-byte charsets like utf-8
How to call it?
The syntax is much the same:
mail()
bool mail ( string $recipient , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
mb_send_mail()
bool mb_send_mail ( string $recipient , string $subject , string $message [, string $additional_headers [, string $additional_parameter ]] )
Text Message Sample Code:
$recipient = 'recipient@yourdomain.tld';
$headers
= 'From: sender@yourdomain.tld';
$subject = 'Hello World';
$message
= 'This is a test';
mail ($recipient, $subject, $message, $headers);
HTML Message Sample Code:
$recipient = 'recipient@yourdomain.tld';
$headers
= 'From: sender@yourdomain.tld';
$headers .="MIME-Version: 1.0\r\nContent-Type:
text/html; charset=iso-8859-1"
$subject = 'Hello World';
$message
= '<html><body><h1>This is a test</h1></body></html>';
mail ($recipient, $subject, $message, $headers);
Add the MIME-Version and the Content-Type to the mail header if you want
to send a message in HTML format.
The MIME-Version is 1.0 and the Content-Type
is "text/html" for a HTML message.
In this sample we use the charset
"iso-8859-1" ... if you want to use mb_send_mail, set the charset
to "utf-8" instead.