PHP code example of wp-spaghetti / wp-mail-transport
1. Go to this page and download the library: Download wp-spaghetti/wp-mail-transport library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Support\Facades\Mail;
Mail::raw('Email body content', function ($message) {
$message->to('[email protected]')
->subject('Test Email');
});
use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeEmail;
Mail::to($user->email)->send(new WelcomeEmail($user));
Mail::send('emails.welcome', ['user' => $user], function ($message) use ($user) {
$message->to($user->email)
->subject('Welcome to our application');
});
Mail::send('emails.invoice', $data, function ($message) use ($user, $pdf) {
$message->to($user->email)
->subject('Your Invoice')
->attach($pdf);
});
// In app/Controllers/ContactController.php
use Illuminate\Support\Facades\Mail;
public function submit(Request $request)
{
Mail::to('[email protected]')->send(
new ContactFormSubmission($request->all())
);
return back()->with('success', 'Message sent!');
}
// In your custom plugins or theme
use Illuminate\Support\Facades\Mail;
add_action('user_register', function($user_id) {
$user = get_userdata($user_id);
Mail::to($user->user_email)->send(
new WelcomeEmail($user)
);
});
use Corcel\Model\User;
use Illuminate\Support\Facades\Mail;
$users = User::published()->get();
foreach ($users as $user) {
Mail::to($user->user_email)->send(
new NewsletterEmail($user)
);
}
Mail::to('[email protected]')->send(new OrderConfirmation($order));
// Uses WP Mail SMTP configuration automatically
Mail::to($user->email)->send(new WelcomeEmail($user));
// Sends through SendGrid via WordPress plugin
Mail::to($subscribers)->send(new Newsletter($content));
// Routes through Mailgun WordPress plugin
// Use WP Mail transport (default)
Mail::to($user)->send(new Welcome($user));
// Use SMTP directly
Mail::mailer('smtp')->to($admin)->send(new Alert($data));