Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

PHP Mail not working


PHP mail() does not seem to be working in and i have tried it in two repls. I would appreciate help as I have looked over the internet and I am a beginner to PHP. error: sh: 1: /usr/sbin/sendmail: not found.

2 years ago
You are viewing a single comment. View All

Hi again,
Please change all the invalid e-mails to your e-mails and try:-

<?php require 'PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = ';'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'secret'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted $mail->From = '[email protected]'; $mail->FromName = 'Mailer'; $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient $mail->addAddress('[email protected]'); // Name is optional $mail->addReplyTo('[email protected]', 'Information'); $mail->addCC('[email protected]'); $mail->addBCC('[email protected]'); $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }

Hope this helps
Please mark my answer if this helps

2 years ago