Mailer scripts in PHP scripting language for sending e-mails
<!-- Mailer scripts in PHP scripting for sending e-mails -->
<?php
ini_set('SMTP', '127.0.0.1');
// Above setting is sometimes necessary e.g., for PHP installation on non-personal server in local network
ini_set('sendmail_from', 'webmaster@example.com');
// Above setting is used commonly
// Example 1
$to = 'user@example.com';
$subject = 'mediasworks.org PHP mailer scripts';
$message = 'PHP mailer scripts simple example\r\n\r\nScripts resource at mediasworks.org';
mail($to, $subject, $message); // text e-mail
// Example 2
$to = 'webmaster@example.com';
$subject = 'mediasworks.com PHP mailer scripts';
$message = 'Handy programming scripts resource reference at <a href="http://www.mediasworks.org/">mediasworks.org</a>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: User 1 <user1@example.com>, User 2 <user2@example.com>, User 3 <user3@example.com>' . "\r\n";
$headers .= 'From: Webmaster <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: user4@example.com' . "\r\n";
$headers .= 'Bcc: user5@example.com' . "\r\n";
// Note the above header settings for HTML format e-mail, To, Cc, Bcc and multiple recipients
mail($to, $subject, $message, $headers);
// Example 3 (other variables from 'Example 2')
// Fifth parameter to mail()
// Envelope sender email address, when -f sendmail option is required in PHP safe_mode enabled
$f_sendmail = '-f' . 'webmaster@example.com'; // '-fwebmaster@example.com'
mail($to, $subject, $message, $headers, $f_sendmail);
?>
<!-- mediasworks.org -->
<!-- mediasworks Group, India and worldwide -->
<!-- mediasworks nonprofit public participation project -->