PHP Send web Mail format (server is Unix), how to solve

Source: Internet
Author: User
Tags php form
PHP Send web Mail format (server is UNIX)
Because the server is the UNIX so with the mail function can send mail, I now want to do is like Chinese talent to send a resume with the format of the kind of ~ ~ ~

------Solution--------------------
What's the dynamic, you mean the message that's inside the message is dynamic, this is very easy ah!
You insert some PHP form variables here (user-input form data), is it OK?
------Solution--------------------
See examples of Phpmail classes
------Solution--------------------

Set the Content-type in the header message of the message
content-type:text/html; charset= "Your Own code"

Set from the 4th parameter of mail.
LZ Reference Document, there are examples
http://jp.php.net/manual/en/function.mail.php
------Solution--------------------
Class SMTP
{
/* Public Variables */
var $smtp _port;
var $time _out;
var $host _name;
var $log _file;
var $relay _host;
var $debug;
var $auth;
var $user;
var $pass;
/* Private Variables */
var $sock;

/* Constractor */
function smtp ($relay _host = "", $smtp _port = +, $auth = False, $user, $pass)
{
$this->debug = FALSE;
$this->smtp_port = $smtp _port;
$this->relay_host = $relay _host;
$this->time_out = 30; is used in Fsockopen ()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; is used in HELO command
$this->log_file = "Error.txt";
$this->sock = FALSE;
}

/* Main Function */
function SendMail ($to, $from, $subject, $body, $mailtype, $cc = "", $BCC = "", $additional _headers = "")
{
$mail _from = $this->get_address ($this->strip_comment ($from));
$body = Ereg_replace ("(^| ( \ \ \)] (\) "," \1.\3 ", $body);
$header = "mime-version:1.0\r\n";

if ($mailtype = = "HTML")
{
$header. = "content-type:text/html;charset=utf-8\r\n";
$header. = "content-transfer-encoding:base64\n\n";
}
$header. = "To:". $to. " \ r \ n ";

if ($cc! = "")
{
$header. = "Cc:". $cc. " \ r \ n ";
}

$header. = "From: $from <". $from. " >\r\n ";
$header. = "Subject:". $subject. " \ r \ n ";
$header. = $additional _headers;
$header. = "Date:". Date ("R"). " \ r \ n ";
$header. = "X-mailer:by Redhat (php/". Phpversion (). ") \ r \ n ";
List ($msec, $sec) = Explode ("", Microtime ());
$TO = Explode (",", $this->strip_comment ($to));

if ($cc! = "")
{
$TO = Array_merge ($TO, Explode (",", $this->strip_comment ($CC)));
}

if ($bcc! = "")
{
$TO = Array_merge ($TO, Explode (",", $this->strip_comment ($BCC)));
}

$this->headers = $header;
$sent = TRUE;

foreach ($TO as $rcpt _to)
{
$RCPT _to = $this->get_address ($rcpt _to);
if (! $this->smtp_sockopen ($rcpt _to))
{
$this->log_write ("Error:cannot send email to". $rcpt _to. " \ n ");
$sent = FALSE;
Continue
}

if ($this->smtp_send ($this->host_name, $mail _from, $rcpt _to, $header, $body))
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.