Laravel - Create and Use free email account at Hostinger using PHPMailer
Most Hostinger hosting plans include a free domain name and email service. If you need more than one email account, you can choose the Premium Web Hosting package, which allows you to create up to 100 domain-based email addresses.
Limit:
namespace App\Helpers; use PHPMailer\PHPMailer\PHPMailer; class EmailHelper { public static function sendEmail(string $senderEmail, string $senderName, string $subject, string $content, string $receiverEmail, string $receiverName) { // if this line does not work //require base_path("vendor/autoload.php"); // use these lines instead require base_path('vendor/phpmailer/phpmailer/src/Exception.php'); require base_path('vendor/phpmailer/phpmailer/src/PHPMailer.php'); require base_path('vendor/phpmailer/phpmailer/src/SMTP.php'); $mail = new PHPMailer(true); $mail->isSMTP(); //$mail->SMTPDebug = 2; // This option will show some debug information on the web page, so remember to remove it on Production. $mail->Host = 'smtp.hostinger.com'; $mail->Port = 587; $mail->SMTPAuth = true; $mail->Username = 'youremailonhostinger@yourdomain.com'; $mail->Password = 'youremailpassword'; $mail->setFrom('someemail@examplexxx.com', 'Some body Name'); $mail->addAddress($receiverEmail, $receiverName); $mail->Subject = 'Email subject'; $mail->msgHTML('Html content'); $mail->Body = 'Or plain text content'; //$mail->addAttachment('attachment.txt'); if (!$mail->send()) { throw new \ErrorException('Mailer Error: ' . $mail->ErrorInfo); } } }
No comments: