本文整理汇总了PHP中Illuminate\Support\Facades\Mail::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail::send方法的具体用法?PHP Mail::send怎么用?PHP Mail::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Mail
的用法示例。
在下文中一共展示了Mail::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send(Collection $data)
{
$validator = $this->validator($data->toArray(), $this->type);
if (!$validator->fails()) {
Mailer::send("emails.{$this->type}", $data->toArray(), function ($message) use($data) {
$fromAddress = $data->get('from_address');
$fromName = $data->get('from_name');
$toAddress = $data->get('to_address');
$toName = $data->get('to_name');
$cc = $data->get('cc[]', []);
$bcc = $data->get('bcc[]', []);
// Send the message
$message->from($fromAddress, $fromName);
$message->to($toAddress, $toName)->subject($data->get('subject'));
foreach ($cc as $address) {
$message->cc($address, null);
}
foreach ($bcc as $address) {
$message->bcc($address, null);
}
});
} else {
// Validation failed
return ['success' => 0, 'status' => "Failed to validate message", 'messages' => $validator->getMessageBag()->all(), 'data' => $data, 'type' => $this->type];
}
if (!count(Mailer::failures())) {
$this->sent_at = Carbon::now();
Log::info("Sent {$this->type} email");
return ['success' => 1, 'status' => "successfully sent message", 'data' => $data, 'type' => $this->type];
}
Log::info("Failed to send {$this->type} email");
return ['success' => 0, 'status' => "failed to send message", 'messages' => "failed to send message", 'data' => $data, 'type' => $this->type];
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$email = $this->argument('email');
$subject = $this->option('subject');
$token = $this->option('token');
$caption = $this->option('caption');
$fullUrl = $this->option('fullUrl');
$headers = $this->option('headers');
$parentClass = $this->option('parentClass');
$exceptionTrace = $this->option('exceptionTrace');
if (is_null($token)) {
Mail::send('emails.' . $this->argument('type') . '', ['name' => $name, 'email' => $email, 'subject' => $subject], function ($mail) use($name, $email, $subject) {
$mail->subject($subject);
$mail->to($email, $name);
});
} else {
switch ($this->argument('type')) {
case "exception":
Mail::send('emails.' . $this->argument('type') . '', ['name' => $name, 'email' => $email, 'subject' => $subject, 'caption' => $caption, 'fullUrl' => $fullUrl, 'headers' => $headers, 'parentClass' => $parentClass, 'exceptionTrace' => $exceptionTrace], function ($mail) use($name, $email, $subject, $caption, $fullUrl, $headers, $parentClass, $exceptionTrace) {
$mail->subject($subject);
$mail->to($email, $name);
});
break;
default:
Mail::send('emails.' . $this->argument('type') . '', ['name' => $name, 'email' => $email, 'token' => $token, 'subject' => $subject], function ($mail) use($name, $email, $subject, $token) {
$mail->subject($subject);
$mail->to($email, $name);
});
}
}
}
示例3: setStatus
/**
* setting methods
*/
public function setStatus($status)
{
$user = $this->getUser();
switch ($status) {
case 'pending':
$this->decline_date = null;
$this->accept_date = null;
$this->save();
$user->owner_flag = 0;
break;
case 'denied':
$this->decline_date = gmdate('Y-m-d H:i:s');
$this->accept_date = null;
$this->save();
Mail::send('emails.ownership-denied', array('user' => $user), function ($message) {
$message->to($this->getUser()->email, $this->getUser()->getFullName());
$message->subject('SWAMP Owner Application Denied');
});
$user->owner_flag = 0;
break;
case 'approved':
$this->accept_date = gmdate('Y-m-d H:i:s');
$this->decline_date = null;
$this->save();
Mail::send('emails.ownership-approved', array('user' => $user), function ($message) {
$message->to($this->getUser()->email, $this->getUser()->getFullName());
$message->subject('SWAMP Owner Application Approved');
});
$user->owner_flag = 1;
break;
}
}
示例4: getCreate
public function getCreate(Request $request)
{
header("Access-Control-Allow-Origin: *");
header("Allow: GET, POST, OPTIONS");
$error = false;
$msg = "";
try {
$nombre = $request->input('nombre');
$dni = $request->input('dni');
$email = $request->input('email');
$password = $request->input('password');
$telefono = $request->input('telefono');
$dominio = $request->input('dominio');
if (User::whereRaw('email=?', [$email])->count() > 0) {
$user = null;
$error = true;
$msg = "Este correo ya ha sido registrado";
} else {
$user = User::create(['name' => $nombre, "dni" => $dni, 'email' => $email, "password" => $password, "telefono" => $telefono]);
$user->codigo = $user->id . date("i") . date("d");
$user->save();
$data = array('url' => $dominio . "/confirmar?mail=" . $user->email . "&confirmar=" . $user->codigo);
Mail::send('mails.confirmacion', $data, function ($message) use($user) {
$message->to($user->email)->subject('Confirmar registro');
});
$msg = "Se envio un correo de confirmmacion a su cuenta de correo";
}
} catch (\Exception $e) {
$user = null;
$error = true;
$msg = $e->getMessage();
}
return ["user" => $user, "error" => $error, "msg" => $msg];
}
示例5: sendEnquireMail
public function sendEnquireMail()
{
$name = Input::get('name');
$email = Input::get('email');
$mobile = Input::get('mobile');
$message2 = Input::get('message');
$result = array();
$validation = $validator = Validator::make(array('Name' => $name, 'email' => $email, 'Mobile' => $mobile, 'Message' => $message2), array('Name' => 'required', 'email' => 'required|email', 'Mobile' => 'required|numeric', 'Message' => 'required'));
if ($validation->fails()) {
$result['status'] = 'Failure';
$result['message'] = 'Fill all fields with valid values';
return response()->json($result);
}
$data['name'] = $name;
$data['email'] = $email;
$data['mobile'] = $mobile;
$data['message2'] = $message2;
Mail::send('mail.enquire', $data, function ($message1) use($data) {
$message1->from($data['email'], $data['name']);
$message1->to('info@oxoniyabuilders.com', 'Enquiry - Oxoniya')->subject('Enquiry - Oxoniya');
});
$result['status'] = 'Success';
$result['message'] = 'Contact Form Successfully Submitted';
return response()->json($result);
}
示例6: sendEmail
/**
* sendEmail : Sends received email to target
*
* @return array : asociative array with the final status of request
*/
public function sendEmail()
{
// Recovers mail data object
$mailData = json_decode(Input::get('emailData'));
//Defines validator object
$validator = Validator::make((array) $mailData, ['email' => array('required', 'regex:/^((<[a-z]+>)?[\\.a-zA-ZáéíóúÁÉÍÓÚñÑ_1-9]+@[a-zA-ZáéíóúÁÉÍÓÚñÑ_-]+\\.[a-zA-ZáéíóúÁÉÍÓÚñÑ]{2,12})(,((<[a-z]+>)?[\\.a-zA-ZáéíóúÁÉÍÓÚñÑ_1-9]+@[a-zA-ZáéíóúÁÉÍÓÚñÑ_-]+\\.[a-zA-ZáéíóúÁÉÍÓÚñÑ]{2,12}))*$/'), 'subject' => array('required', 'regex:/^[a-zA-ZáéíóúÁÉÍÓÚñÑ1-9][a-zA-ZáéíóúÁÉÍÓÚñÑ1-9 ]{3,50}$/')]);
// Returns fail message if validation fails
if ($validator->fails()) {
return response()->json(['status' => 'fail'], 200);
} else {
// Split string of emails into an array of emails
$allMails = explode(',', $mailData->email);
// For each mail in $allMails, actual name and target of each mail are getted, and then the email is sent
foreach ($allMails as $mail) {
$separatorPosition = strpos($mail, '>');
if ($separatorPosition) {
$name = substr($mail, 1, $separatorPosition - 1);
$target = substr($mail, $separatorPosition + 1);
} else {
$target = $mail;
$name = '';
}
Mail::send([], [], function ($message) use($mailData, $target, $name) {
$message->to($target, $name);
$message->subject($mailData->subject);
$message->setBody($mailData->htmlContent, 'text/html');
});
}
return response()->json(['status' => 'success'], 200);
}
}
示例7: sendContactForm
public function sendContactForm()
{
$is_mail_sent = false;
// Get data
$lastname = post('lastname');
$firstname = post('firstname');
$email = post('email');
$subject = post('subject');
$message_body = post('message');
$inputs = ['lastname' => $lastname, 'firstname' => $firstname, 'email' => $email, 'subject' => $subject, 'message' => $message_body];
$rules = ['lastname' => 'required', 'firstname' => 'required', 'email' => 'required|email', 'subject' => 'required', 'message' => 'required'];
$messages = ['lastname.required' => 'contactForm.lastname_required', 'firstname.required' => 'contactForm.firstname_required', 'email.required' => 'contactForm.email_required', 'email.email' => 'contactForm.email_invalid', 'subject.required' => 'contactForm.subject_required', 'message.required' => 'contactForm.message_required'];
// Data Validation
$validator = Validator::make($inputs, $rules, $messages);
if ($validator->fails()) {
$messages = $validator->messages();
$this->page["inputs"] = $inputs;
$this->page["messages"] = $messages;
return;
}
$data = compact('firstname', 'lastname', 'email', 'subject', 'message_body');
$is_mail_sent = Mail::send('algad.bootstrap::mail.contactform.message', $data, function ($message) use($firstname, $lastname, $email) {
$message->from($email, $firstname . " " . $lastname);
$message->addReplyTo($email, $lastname . ' ' . $firstname);
$message->to($this->getProperty('recipient_email'));
});
if ($is_mail_sent) {
$this->page["contact_success_message"] = $this->getProperty('email_sent_confirmation');
} else {
$this->page["contact_error_message"] = $this->getProperty('email_sent_failed');
}
}
示例8: post
/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function post(Request $request)
{
$data['title'] = $request->bugTitle;
$data['description'] = $request->bugDescription;
$data['controller'] = $request->controller;
if (!Auth::user()) {
$data['email'] = $request->bugEmail;
$data['name'] = $request->bugName;
$validator = Validator::make($request->all(), ['bugEmail' => 'required|email|max:255', 'bugName' => 'required|max:255|alpha_space', 'bugTitle' => 'required|max:255', 'bugDescription' => 'required|max:255']);
} else {
$data['email'] = Auth::user()->email;
$data['name'] = Auth::user()->name;
$validator = Validator::make($request->all(), ['bugTitle' => 'required|max:255|email', 'bugDescription' => 'required|max:255']);
}
if ($validator->fails()) {
return back()->withErrors($validator)->withInput()->with('modal', true);
}
$response = Mail::send('emails.ladybug', $data, function ($message) use($data) {
$message->from($data['email'], $data['name']);
$message->subject("Bug Report");
$message->to('admin@uir-events.com');
});
if ($response) {
return back()->with('success', 'Your report has been sent.');
} else {
return back()->with('error', 'An error occured, please try again.');
}
}
示例9: sendEmailContact
/**
* Send an e-mail reminder to the user.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function sendEmailContact(Request $request)
{
//return response()->json($request->all());
$test = $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email', 'phone' => 'required|digits:10', 'message' => 'required']);
/*
_token: "b0cehzEEK2fbzXilKcI9CiijhEClyBIXkvTpPCze",
name: "Tonny Wijnand",
email: "tonnywijnand@gmail.com",
phone: "0615061892",
message: "TEST"
*/
//return $test;
/*
if ($this->validator->fails()) {
return redirect('post/create')
->withErrors($validator)
->withInput();
}
*/
//dc($request->all());
$user = (object) ['from' => 'info@pyxis-projekten.nl', 'fromName' => 'Pyxis Projeckmanagement', 'to' => 'tonnywijnand@gmail.com', 'toName' => 'Tonny Wijnand', 'subject' => 'Contact formulier via website pyxis'];
$test = Mail::send(['emails.contact-form', 'emails.contact-form-text'], ['user' => $user], function ($m) use($user) {
//$m->from('hello@app.com', 'Your Application');
//$m->to($user->email, $user->name)->subject('Your Reminder!');
$m->from($user->from, $user->fromName);
$m->to($user->to, $user->toName)->subject($user->subject);
});
$data = ['status' => 'success', 'statusText' => 'Update is gelukt', 'responseText' => 'De volgorde is aangepast', 'mail' => $test];
return response()->json($data);
}
示例10: sendquotation
public function sendquotation()
{
$input = Input::all();
$name = $input['name'];
$email_client = $input['email'];
$phone_client = $input['phone'];
$title = $input['title'];
$msg_webneoo = nl2br($input['msg_webneoo']);
Mail::send('emails.quotation', ['name' => $name, 'email_client' => $email_client, 'phone_client' => $phone_client, 'msg_webneoo' => $msg_webneoo], function ($m) use($email_client, $title) {
$m->from($email_client, 'Webneoo')->subject($title);
$m->to('info@webneoo.com');
});
/*Mail::send('emails.contact', array('name' => $name, 'email_client' => $email_client, 'subject_client' => $subject_client, 'msg_webneoo' => $msg_webneoo), function($message) use ($email_client)
{
$message->from($email_client, 'Webneoo')->subject('From Webneoo Website');
$message->to('info@webneoo.com');
});*/
/*Mail::send('emails.quotation', array('name' => $name, 'email_client' => $email_client,
'subject_client' => $subject_client, 'msg_webneoo' => $msg_webneoo),
function($message) use ($email_client, $title)
{
$message->from($email_client, 'Webneoo')->subject($title);
$message->to('info@webneoo.com');
});*/
return View::make('pricing.index');
}
示例11: sendNotification
/**
* Send email notifications from the action owner to other involved users
* @param string $template
* @param array $data
* @param object $ticket
* @param object $notification_owner
*/
public function sendNotification($template, $data, $ticket, $notification_owner, $subject, $type)
{
if (config('ticketit.queue_emails') == 'yes') {
Mail::queue($template, $data, function ($m) use($ticket, $notification_owner, $subject, $type) {
if ($type != 'agent') {
if ($ticket->user->email != $notification_owner->email) {
$m->to($ticket->user->email, $ticket->user->name);
}
if ($ticket->agent->email != $notification_owner->email) {
$m->to($ticket->agent->email, $ticket->agent->name);
}
} else {
$m->to($ticket->agent->email, $ticket->agent->name);
}
$m->from($notification_owner->email, $notification_owner->name);
$m->subject($subject);
});
} else {
Mail::send($template, $data, function ($m) use($ticket, $notification_owner, $subject, $type) {
if ($type != 'agent') {
if ($ticket->user->email != $notification_owner->email) {
$m->to($ticket->user->email, $ticket->user->name);
}
if ($ticket->agent->email != $notification_owner->email) {
$m->to($ticket->agent->email, $ticket->agent->name);
}
} else {
$m->to($ticket->agent->email, $ticket->agent->name);
}
$m->from($notification_owner->email, $notification_owner->name);
$m->subject($subject);
});
}
}
示例12: send
public function send()
{
if ($this->to && $this->body && $this->subject) {
$data = array("body" => $this->body);
//save in logs
$this->doAddMailer();
Mail::send('mail-templates::email_body', $data, function ($message) {
if (strpos($this->to, ",")) {
$toArray = explode(",", $this->to);
foreach ($toArray as $email) {
$email = trim($email);
$message->to($email)->subject($this->subject);
}
} else {
$message->to($this->to)->subject($this->subject);
}
//if isset attach file
if ($this->attach) {
if (is_array($this->attach)) {
foreach ($this->attach as $attach) {
$message->attach($attach->getRealPath(), array('as' => $attach->getClientOriginalName(), 'mime' => $attach->getMimeType()));
}
} else {
$message->attach($this->attach->getRealPath(), array('as' => $this->attach->getClientOriginalName(), 'mime' => $this->attach->getMimeType()));
}
}
});
return true;
} else {
return false;
}
}
示例13: userSignUp
/**
* iLife iOS Backend API No.2
* @param Request $request
* @return string
*/
public function userSignUp(Request $request)
{
// Check whether this user exist
$user = User::where('email', '=', $request->email)->get();
if (sizeof($user) == 1) {
$result = array('code' => 3, 'message' => 'Cannot signup, email has been registered', 'data' => null);
return json_encode($result);
}
// If user does not exists, register a new user
$new_user = new User();
$new_user->name = $request->name;
$new_user->email = $request->email;
$new_user->password = bcrypt($request->password);
$new_user->save();
// Send user an email after successfully registration
$user_data['name'] = $request->name;
$data['email'] = $request->email;
Mail::send('email_reply/register_reply', $user_data, function ($message) use($data) {
$message->from('no-reply@ilife.ie', "iLife");
$message->subject("Welcome to iLife");
$message->to($data['email']);
});
$result = array('code' => 1000, 'message' => 'Sign up succeed', 'data' => $new_user->id);
return json_encode($result);
}
示例14: sendConfirmationEmail
public function sendConfirmationEmail($user)
{
return Mail::send('emails.users.rsvp-confirm', ['user' => $user], function ($m) use($user) {
$m->to($user->email, $user->name)->subject('Camp Schwartzelrod is 6 weeks away!');
//$m->to('schwartzelrods@gmail.com', $user->name)->subject('Camp Schwartzelrod is 6 weeks away!');
});
}
示例15: invitation
/**
* Send balin invitation
*
* @param user, store
* @return JSend Response
*/
public function invitation()
{
$user = Input::get('user');
$email = Input::get('email');
$store = Input::get('store');
// checking user data
if (empty($user)) {
throw new Exception('Sent variable must be array of a record.');
}
// checking email data
if (empty($email) || !is_array($email)) {
throw new Exception('Sent variable must be array of a record.');
}
// checking store data
if (empty($store)) {
throw new Exception('Sent variable must be array of a record.');
}
$data = ['user' => $user, 'balin' => $store];
foreach ($email as $key => $value) {
//send mail
Mail::send('mail.' . $this->template . '.account.invitation', ['data' => $data], function ($message) use($user, $value) {
$message->to($value['email'], $value['email'])->subject(strtoupper($this->template) . ' INVITATION FROM ' . strtoupper($user['name']));
});
}
return new JSend('success', (array) Input::all());
}