$mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPAuth = true; $mail->Host = 'smtp.gmail.com'; $mail->Username = 'your_email@gmail.com'; $mail->Password = 'your_email_password'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('your_email@gmail.com', 'Your Name'); $mail->addAddress('recipient_email@gmail.com', 'Recipient Name'); $mail->isHTML(true); $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email sent using PhpMailer.'; if(!$mail->send()) { echo 'Message not sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent.'; }
$client = new GuzzleHttp\Client(); $res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); echo $res->getStatusCode(); // 200 echo $res->getHeaderLine('content-type'); // 'application/json; charset=utf8' echo $res->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
use Intervention\Image\ImageManagerStatic as Image; $image = Image::make('public/image.png')->resize(300, 200)->save('public/resized.png');
use Carbon\Carbon; $now = Carbon::now(); $nextWeek = Carbon::now()->addWeek(); $difference = $now->diffInDays($nextWeek); echo "Next week will be $difference days from now.";
use Dotenv\Dotenv; $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); echo getenv('DB_USERNAME'); // 'john_doe'