本文整理汇总了PHP中mail::type方法的典型用法代码示例。如果您正苦于以下问题:PHP mail::type方法的具体用法?PHP mail::type怎么用?PHP mail::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mail
的用法示例。
在下文中一共展示了mail::type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smtp
function smtp($to, $semi_rand)
{
$header = "Date: " . date("D, j M Y G:i:s") . " +0700\r\n";
if (self::$from_name) {
$header .= "From: =?utf-8?Q?" . str_replace("+", "_", str_replace("%", "=", urlencode(self::$from_name))) . "?= <" . self::$from_email . ">\r\n";
} else {
$header .= "From: " . self::$from_email . "\r\n";
}
//$header .= "X-Mailer: The Bat! (v3.99.3) Professional\r\n";
//$header .= "Reply-To: =?utf-8?Q?".str_replace("+","_",str_replace("%","=",urlencode('Максим')))."?= <lessio@lessio.ru>\r\n";
if (self::$html) {
$text = self::$html;
} else {
if (self::$text) {
self::$type = 'plain';
$text = self::$text;
}
}
$header .= "X-Priority: 3 (Normal)\r\n";
$header .= "Message-ID: <172562218." . date("YmjHis") . ">\r\n";
$header .= "To: " . $to . "\r\n";
$header .= "Subject: =?utf-8?Q?" . str_replace("+", "_", str_replace("%", "=", urlencode(self::$subject))) . "?=\r\n";
$header .= "MIME-Version: 1.0\r\n";
if (self::$file) {
$header .= "Content-Type: multipart/mixed; boundary=\"----------{$semi_rand}\"\r\n";
$file = self::$file;
$fileatttype = self::MIMEType($file);
$fileattname = basename($file);
$fp = fopen($file, "rb");
$code_file = chunk_split(base64_encode(fread($fp, filesize($file))));
fclose($fp);
$text = "------------{$semi_rand}\r\nContent-Type: text/html; charset=\"utf-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" . $text . "\r\n\r\n------------{$semi_rand}\r\nContent-Type: {$fileatttype}; name=\"{$fileattname}\"\r\nContent-transfer-encoding: base64\r\nContent-Disposition: attachment; filename=\"{$fileattname}\"\r\n\r\n" . $code_file . "\r\n------------{$semi_rand}--\r\n";
} else {
$header .= "Content-Type: text/" . self::$type . "; charset=utf-8\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n";
}
$smtp_conn = fsockopen(self::$smtp_host, self::$smtp_port, $errno, $errstr, 10);
if (!$smtp_conn) {
print "соединение с серверов не прошло";
fclose($smtp_conn);
exit;
}
$data = self::get_data($smtp_conn);
fputs($smtp_conn, "EHLO " . self::$smtp_host . "\r\n");
$code = substr(self::get_data($smtp_conn), 0, 3);
if ($code != 250) {
print "ошибка приветсвия EHLO";
fclose($smtp_conn);
exit;
}
/*
auth
fputs($smtp_conn,"AUTH LOGIN\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 334) {print "сервер не разрешил начать авторизацию"; fclose($smtp_conn); exit;}
fputs($smtp_conn,base64_encode("login")."\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 334) {print "ошибка доступа к такому юзеру"; fclose($smtp_conn); exit;}
fputs($smtp_conn,base64_encode("password")."\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 235) {print "не правильный пароль"; fclose($smtp_conn); exit;}
*/
fputs($smtp_conn, "MAIL FROM:" . self::$from_email . "\r\n");
$code = substr(self::get_data($smtp_conn), 0, 3);
if ($code != 250) {
print "сервер отказал в команде MAIL FROM";
fclose($smtp_conn);
exit;
}
fputs($smtp_conn, "RCPT TO:" . $to . "\r\n");
$code = substr(self::get_data($smtp_conn), 0, 3);
if ($code != 250 and $code != 251) {
print "Сервер не принял команду RCPT TO";
fclose($smtp_conn);
exit;
}
fputs($smtp_conn, "DATA\r\n");
$code = substr(self::get_data($smtp_conn), 0, 3);
if ($code != 354) {
print "сервер не принял DATA";
fclose($smtp_conn);
exit;
}
fputs($smtp_conn, $header . "\r\n" . $text . "\r\n.\r\n");
$code = substr(self::get_data($smtp_conn), 0, 3);
if ($code != 250) {
print "ошибка отправки письма";
fclose($smtp_conn);
exit;
}
fputs($smtp_conn, "QUIT\r\n");
fclose($smtp_conn);
self::clear();
return true;
}