本文整理匯總了PHP中mail函數的典型用法代碼示例。如果您正苦於以下問題:PHP mail函數的具體用法?PHP mail怎麽用?PHP mail使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了mail函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendmail
function sendmail()
{
global $curtime;
global $backupfile;
global $archname;
$text = "整站文件備份" . $backupfile;
$subject = $backupfile;
$from = 'wordpress@suifeng.me';
$to = 'webmaster@suifeng.me';
$file = $archname;
$boundary = uniqid("");
$headers = "From:{$from}\r\n";
$headers .= "Content-type:multipart/mixed; boundary= {$boundary}\r\n";
$mimeType = "application/x-bzip2";
$fileName = $backupfile;
$fp = fopen($file, "r");
$read = fread($fp, filesize($file));
$read = base64_encode($read);
$read = chunk_split($read);
$body = "--{$boundary}\nContent-type:text/plain; charset=utf-8\nContent-transfer-encoding: 8bit\n{$text}\n文件:{$backupfile}\n備份日期:{$curtime}\n--{$boundary}\nContent-type: {$mimeType}; name={$fileName}\nContent-disposition: attachment; filename={$fileName}\nContent-transfer-encoding: base64\n{$read}\n--{$boundary}--";
if (mail($to, $subject, $body, $headers)) {
print "OK! Now the mail from {$from} ---to--- {$to} has been send<br>";
} else {
print "fail to send mail <br>";
}
}
示例2: sendNotifEmail
function sendNotifEmail($toId, $from, $type, $id)
{
$username = "uv023890";
$password = "porotos1";
$hostname = "localhost";
$db = "comm";
$db = new mysqli($hostname, $username, $password, $db);
$db->set_charset("utf8");
$to = $db->query("SELECT user FROM tblusers WHERE userId='" . $toId . "'")->fetch_array();
switch ($type) {
case 0:
//Photo
$link = "http://comunidad.nitragin.com.ar/album.php?id=" . $id;
$text = "album de fotos";
break;
case 1:
//File
$link = "http://comunidad.nitragin.com.ar/file.php?id=" . $id;
$text = "archivo";
break;
case 2:
//Message
$link = "http://comunidad.nitragin.com.ar/msg.php?id=" . $id;
$text = "mensaje";
break;
}
$email = '<!DOCTYPE html ><html><body><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/><center><table id="wrapper" width="600" cellspacing="0" cellpadding="0" border="0" ><tr><td style="padding:0px;border-collapse:collapse;font-family:Arial, Helvetica, sans-serif;text-align: center"><img style="border:0;height:auto;line-height:100%;outline:none;text-decoration:none;float:left;" width="600" height="67" src="http://comunidad.nitragin.com.ar/mailing/notif/img/header.png"/></a></td></tr><tr><td style="border-collapse:collapse;padding-right:31px;font-family:Helvetica, sans-serif;padding-top:25px;"><table style="margin:0;"><tr><td style="padding:0;padding-left:150px;border-collapse:collapse;font-family:Arial, Helvetica, sans-serif;text-align: center;padding-top:20px;" ><img width="44" height="44" src="http://comunidad.nitragin.com.ar/mailing/notif/img/msg.png"/ style="float:right;border:0;height:auto;line-height:100%;outline:none;text-decoration:none;"><br></td><td style="padding:0;border-collapse:collapse;font-family:Arial, Helvetica, sans-serif;text-align: center;padding-top:10px;"><p style="font-family:Helvetica, sans-serif;float:left;font-size:15px;color:#66686A;margin:0;mso-line-height-rule:exactly;line-height:13px;text-align: left;">Has recibido un nuevo mensaje de<br>' . $from . '</p></td></tr></table></td></tr><tr><td style="border-collapse:collapse;font-family:Helvetica, sans-serif;text-align:center;padding-bottom:40px;"><table style="margin:0;"><tr><td style="padding:0;border-collapse:collapse;font-family:Arial, Helvetica, sans-serif;text-align: center;padding-left:240px;" ><a href="' . $link . '"><img src="http://comunidad.nitragin.com.ar/mailing/notif/img/more.png" width="53" height="20"></a></td></tr></table></td></tr><tr><td style="border-collapse:collapse;font-family:Helvetica, sans-serif;text-align:center;background-color:#3F2B3C"><table style="margin:0;"><tr><td style="padding:7px 0px;padding-left:20px;border-collapse:collapse;font-family:Arial, Helvetica, sans-serif;text-align: left;" ><img width="139" height="20" src="http://comunidad.nitragin.com.ar/mailing/notif/img/commL.png"/ style="float:right;border:0;height:auto;line-height:100%;outline:none;text-decoration:none;"><br></td></tr></table></td></tr></table></center><style type="text/css">table{font-family:Arial, Helvetica, sans-serif;border:0;}p{text-align:justify;}</style><style type="text/css">/* Client-specific Styles */#outlook a{padding:0;}/* Force Outlook to provide a "view in browser" button. */body{width:100% !important;}.ReadMsgBody{width:100%;}.ExternalClass{width:100%;}/* Force Hotmail to display emails at full width */body{-webkit-text-size-adjust:none;}/* Prevent Webkit platforms from changing default text sizes. *//* Reset Styles */body{margin:0px auto;padding:0;font-family:Arial, Helvetica, sans-serif;}img{border:0;height:auto;line-height:100%;outline:none;text-decoration:none;float:left;}</style></body></html>';
$subject = "Nueva notificacion en Nitragin Comunidad";
$fromM = "community@nitragin.com.ar";
$headers = "From:" . $fromM . "\r\n";
$headers .= "Reply-To:soporte@nitragin.com.ar\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to['user'], $subject, $email, $headers);
}
示例3: notifica
public function notifica($assunto_mail, $name, $assunto, $descricao)
{
$email_nyx = "suporte@squad.net.br";
$destino = "renan@squad.net.br";
if (PATH_SEPARATOR == ":") {
$quebra = "\r\n";
} else {
$quebra = "\n";
}
//composição do corpo do e-mail para o destinatário
$corpo = "MIME-Version: 1.1" . $quebra;
$corpo .= "Content-type: text/plain; charset=utf-8" . $quebra;
$corpo .= "From: " . $email_nyx . $quebra;
//E-mail do remetente
$corpo .= "Return-Path: " . $email_nyx . $quebra;
//E-mail do remetente
$corpo = "De:" . $quebra;
$corpo .= "Nome: " . $name . $quebra;
$corpo .= "Assunto: " . $assunto . $quebra;
$corpo .= "Mensagem:" . $quebra;
$corpo .= $descricao;
$headers = 'From: ' . $email_nyx . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($destino, $assunto_mail, $corpo, $headers);
//echo $destino.'<br>'.$assunto_mail.'<br>'.$corpo.'<br>'.$headers;
}
示例4: actionToken
public function actionToken($state)
{
// only poeple on the list should be generating new tokens
if (!$this->context->token->checkAccess($_SERVER['REMOTE_ADDR'])) {
echo "Oh sorry man, this is a private party!";
mail($this->context->token->getEmail(), 'Notice', 'The token is maybe invalid!');
$this->terminate();
}
// facebook example code...
$stoken = $this->session->getSection('token');
if (!isset($_GET['code'])) {
$stoken->state = md5(uniqid(rand(), TRUE));
//CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&scope=" . $this->context->token->getAppPermissions() . "&state=" . $stoken->state;
echo "<script> top.location.href='" . $dialog_url . "'</script>";
$this->terminate();
}
if (isset($stoken->state) && $stoken->state === $_GET['state']) {
$token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&client_secret=" . $this->context->token->getAppSecret() . "&code=" . $_GET['code'];
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$date = new DateTime();
$date->add(new DateInterval('PT' . $params["expires"] . 'S'));
$this->context->token->saveToken($params['access_token'], $date);
echo "Thanks for your token :)";
} else {
echo "The state does not match. You may be a victim of CSRF.";
}
$this->terminate();
}
示例5: do_order
function do_order ()
{
global $scanner, $dep, $db;
# Get context position.
$table = $scanner->context_table;
$id = $scanner->context['id'];
$scanner->push_context ();
# Send order.
$from =& cms_fetch_object ('d_order_address');
if (!$from)
panic ('No order address specified.');
$template =& cms_fetch_object ('l_order_email');
if (!$template)
panic ('No order template specified.');
$tree =& $scanner->scan ($template);
$body = $scanner->exec ($tree, $table, $id);
mail ($from, $_SERVER['SERVER_NAME'] . " - e-shop", htmllig2latin ($body)); # TODO subject attribute
# Send confirmation.
$subject =& cms_fetch_object ('d_order_email_subject');
if (!$subject)
panic ('No order email subject.');
$to = dirtag_order_shipto (array ('field' => 'email'));
$template =& cms_fetch_object ('l_order_confirm');
if (!$template)
panic ('No order confirmation template.');
$tree =& $scanner->scan ($template);
$body = $scanner->exec ($tree, $table, $id);
mail ($to, $subject, htmllig2latin ($body), "From: $from\nReply-To: $from");
$scanner->pop_context ();
}
示例6: enviar_correo
function enviar_correo($mensaje, $asunto, $para, $de)
{
$mensaje_contacto = "{$mensaje}";
$asunto = "{$asunto}";
$casilla = "{$para}";
$cabeceras = "From: {$de}\r\n";
$cabeceras .= "MIME-Version: 1.0\r\n";
$cabeceras .= "Content-Type: text/html; charset=UTF-8\r\n";
$mensaje = '<!doctype html>';
$mensaje .= '<html>';
$mensaje .= '<head>';
$mensaje .= '<meta charset="UTF-8">';
$mensaje .= '<title>Contacto WEB</title>';
$mensaje .= '<meta name="viewport" content="width=device-width, initial-scale=1">';
$mensaje .= '<link rel="stylesheet" href="http://nfn.cl/src/bootstrap.css" media="screen">';
$mensaje .= '<link rel="stylesheet" href="http://nfn.cl/src/app.css" media="screen">';
$mensaje .= '</head>';
$mensaje .= '<body>';
$mensaje .= '<div class="container">';
$mensaje .= '<div class="row margin-bottom-30"></div>';
$mensaje .= ' <div class="row">';
$mensaje .= ' <div class="col-lg-2 hidden-sm"></div>';
$mensaje .= ' <div class="col-lg-6 col-sm-12 col-md-6"> ';
$mensaje .= "\t\t\t<p class=\"text-left\">{$mensaje_contacto}</p>";
$mensaje .= ' </div>';
$mensaje .= ' </div>';
$mensaje .= '</div>';
$mensaje .= '</body>';
$mensaje .= '</html>';
mail($casilla, $asunto, $mensaje, $cabeceras);
}
示例7: indexAction
public function indexAction(Request $request)
{
$name = $request->request->get('name');
$phone = $request->request->get('phone');
$time = $request->request->get('time');
$type = $request->request->get('type');
switch ($type) {
case 'group':
$typeInfo = "в группе";
break;
case 'individ':
$typeInfo = "индивидуально";
break;
case 'company':
$typeInfo = "корпоративно";
break;
default:
$typeInfo = "";
break;
}
$to = 'irk@e-a-s-y.ru';
$subject = 'Запрос с сайта';
$message = "Имя: {$name}, Номер: {$phone}, Время: {$time}, Тип занятий:{$typeInfo}";
$headers = 'From: irk@e-a-s-y.ru' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
//var_dump(mail($to, $subject, $message, $headers));die();
if (mail($to, $subject, $message, $headers)) {
echo "sended";
die;
} else {
echo "not sended";
die;
}
}
示例8: HackingLog
function HackingLog()
{
echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
Warehouse('footer');
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if ($openSISNotifyAddress) {
mail($openSISNotifyAddress, 'HACKING ATTEMPT', "INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
}
/*if($openSISNotifyAddress)
mail($openSISNotifyAddress,'HACKING ATTEMPT',"INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");*/
if (false && function_exists('mysql_query')) {
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$link = @mysql_connect('os4ed.com', 'openSIS_log', 'openSIS_log');
@mysql_select_db('openSIS_log');
@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
@mysql_close($link);
/*$link = @mysql_connect('os4ed.com','openSIS_log','openSIS_log');
@mysql_select_db('openSIS_log');
@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
@mysql_close($link);*/
}
}
示例9: send
/**
* Sends the mail
*
* @returns
* - true on success
* - html-error on failure
*
* NOTE some tips used from Jon Webb [Madrid&London]
* http://www.php.net/manual/en/ref.mail.php#61644
*/
public function send()
{
if ($this->errors) {
return false;
}
$eol = "\n";
#getEndOfLine();
$boundary = "-streber--------------------------------------";
### headers ###
$headers = "";
$headers .= "Content-Type: multipart/alternative; boundary=\"" . $boundary . "\"" . $eol;
$headers .= "From: {$this->from}" . $eol;
$headers .= 'MIME-Version: 1.0' . $eol;
$msg = "Content-Type: multipart/alternative" . $eol . "--" . $boundary . $eol . "Content-Type: text/plain; charset=UTF-8" . $eol . $eol . $this->body_plaintext . $eol . "--" . $boundary . $eol . "Content-Type: text/html; charset=UTF-8" . $eol . $eol . $this->body_html . $eol . $eol . "--" . $boundary . "--" . $eol . $eol;
/**
* NOTE: capturing error-output of mail is done in errorhandler.inc,
* it sets the global variable $g_error_mail
*/
mail($this->to, $this->subject, $msg, $headers);
global $g_error_mail;
if (isset($g_error_mail)) {
$error = asHtml($g_error_mail . ' ("' . $to . '" <' . $this->recipient->name . '>)');
$g_error_mail = NULL;
return $error;
}
return true;
}
示例10: forgotPassword
public function forgotPassword()
{
$view = new Template('Member/forgot-password');
$view->text = '<strong>Please fill in your email address below and we\'ll send you a link to reset your password.</strong><br><br>';
$view->form = $this->forgotPasswordForm();
if ($this->request->getMethod() == 'POST') {
$member = Store::get('Contact')->getByEmail($this->getParam('email'));
if (is_null($member)) {
$view->errorMessage = 'There is no account registered with that email address.';
}
if (!is_null($member)) {
$key = $this->getResetKey($member);
$email = new Template('Member/forgot-password-email');
$email->member = $member;
$email->key = $key;
$html = $email->render();
$to = $member->getFirstName() . ' ' . $member->getLastName() . ' <' . $member->getEmail() . '>';
$name = $this->config->get('site.name');
$from = $this->config->get('site.email_from');
@mail($to, 'Reset Your ' . $name . ' Password', $html, 'From: ' . $from . PHP_EOL . 'Content-Type: text/html');
$view->form = null;
$view->text = 'Thanks, we\'ve emailed you a link to reset your password.';
}
}
return $view->render();
}
示例11: pun_mail
function pun_mail($to, $subject, $message, $from = '')
{
global $pun_config, $lang_common;
$sender = str_replace('"', '', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer']);
// Default sender/return address
if (!$from) {
$from = '"=?UTF-8?B?' . base64_encode($sender) . '?=" <' . $pun_config['o_webmaster_email'] . '>';
}
// Do a little spring cleaning
$to = trim(preg_replace('#[\\n\\r]+#s', '', $to));
$subject = trim(preg_replace('#[\\n\\r]+#s', '', $subject));
$from = trim(preg_replace('#[\\n\\r:]+#s', '', $from));
$subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
$headers = 'From: ' . $from . "\r\n" . 'Date: ' . date('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n" . 'X-Mailer: PunBB Mailer';
// Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
$message = str_replace(array("\n", ""), array("\r\n", ''), pun_linebreaks($message));
if ($pun_config['o_smtp_host']) {
return smtp_mail($to, $subject, $message, $headers);
} else {
// Change the linebreaks used in the headers according to OS
if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC') {
$headers = str_replace("\r\n", "\r", $headers);
} else {
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$headers = str_replace("\r\n", "\n", $headers);
}
}
return mail($to, $subject, $message, $headers);
}
}
示例12: sendemail
function sendemail()
{
if (isset($_POST['action']) and $_POST['action'] == 'send') {
$body = BODY;
if (!is_string($_POST['name']) or $_POST['name'] == '') {
return '<p class="error">Insert correct name</p>';
}
if (!is_email($_POST['email']) or $_POST['email'] == '') {
return '<p class="error">Insert correct email</p>';
}
$subject = $_POST['subject'];
if (!is_email($subject) or $subject == '') {
$subject = 'Email without subject.';
}
foreach (array_map('stripslashes', $_POST) as $id => $var) {
if ($id == 'message') {
$var = nl2br($var);
}
$body = str_replace("%{$id}%", $var, $body);
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "From: myplace@here.com\r\n";
$sendmail = mail(TO, $subject, $body, $headers);
if ($sendmail) {
return '<p class="success">Email sent correctly!</p>';
} else {
return '<p class="error">An error has been encountered. Please try again.</p>';
}
}
}
示例13: call_authcode_text
function call_authcode_text()
{
global $id,$confirm,$Aname,$tool;
include_once('inc/functions/resort_tools.php');
if (! user_has_access($tool))
{
echo "Sorry, this page is restricted to ORKFiA Staff";
include_game_down();
exit;
}
ECHO "<p>Just enter verified to stop the auth request, or to require them to read their new email use something random.</p>";
echo "<form method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">";
ECHO "Input ID#: <input name=id size=5><br>";
ECHO "Change authcode to: <input type=text name=Aname maxlength=30 size=25><br>";
ECHO "<input type=submit value=Send name=confirm>";
ECHO "</form>";
ECHO "<br><br>";
IF($confirm && $id && $Aname)
{
$result = mysql_query("UPDATE preferences SET email_activation = '$Aname' where id = $id");
$result = mysql_query ("SELECT * FROM preferences WHERE id = $id");
$check =mysql_fetch_array($result);
ECHO "<p>Activation code changed to: $Aname . Email sent to $check[email]</p>";
mail("$check[email]","ORKFiA Activation","Welcome to ORKFiA =) \n\nHere is your activation code: $Aname \n\n\nIt is recommended you tend to your tribe at least once per day. If you require help or this is your first time playing ORKFiA, you may find the forums and the manual useful.\n\nWe hope you enjoy this age in ORKFiA =)\n\n- The ORKFiA Team\n\n\nThis email is php generated, you cannot successfully reply." , "From: Admins@orkfia.net");
}
}
示例14: sendEmail
function sendEmail($name, $Email, $subject, $message, $recipient)
{
$siteURL = getSiteURL();
// Email layout
$formatedMessage = '<html>
<head>
<title>
' . $subject . '
</title>
</head>
<body>
<div class="email">
<p>
Ce message vous à été envoyé depuis
<a href="' . $siteURL . '">
' . $siteURL . '
</a>
par ' . $name . '.
</p>
<p>' . $message . '</p>
</div>
</body>
</html>';
// Headers definition
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: ' . $recipient . "\r\n";
$headers .= 'From: ' . $name . '<' . $Email . '>' . "\r\n";
$headers .= 'Subject: ' . $subject . "\r\n";
// Send and return state
return mail($recipient, $subject, $formatedMessage, $headers);
}
示例15: sendEmail
public function sendEmail($email, $subject, $input = NULL)
{
$this->input = $input;
$this->email = $email;
self::display($subject);
mail($this->email, $this->subjectTitle, $this->emailContentHtml, $this->header);
}