phpmailerHow do I configure PHPmailer to use Zoho SMTP?
- Install the latest version of PHPmailer using composer by running the command
composer require phpmailer/phpmailer
- Create a new instance of the PHPmailer class and set the SMTP host, username, and password for Zoho SMTP.
$mail = new PHPMailer; $mail->isSMTP(); $mail->Host = 'smtp.zoho.com'; $mail->SMTPAuth = true; $mail->Username = '[email protected]'; $mail->Password = 'password';
- Set the SMTP port, encryption, and authentication type.
$mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuthType = 'LOGIN';
- Set the sender and recipient information.
$mail->setFrom('[email protected]', 'Mailer'); $mail->addAddress('[email protected]', 'User');
- Set the subject and body of the message.
$mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- Send the message and check for errors.
if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }
- Output:
Message has been sent
Helpful links
More of Phpmailer
- How can I configure PHPMailer to support Polish characters?
- How do I use PHPMailer to attach a ZIP file?
- How can I use PHPMailer in Yii 1?
- How do I determine which version of PHPMailer I'm using?
- How can I use PHPMailer without SMTP secure?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer to send emails with a Yahoo account?
- How do I use PHPMailer to encode emails in UTF-8?
- How do I set the X-Mailer header using PHPMailer?
See more codes...