Search code examples
phpmailerpopen

Using PHPMailer when popen is disabled


Is it possible to use PHPMailer to send an email from a php script on shared hosting where popen() is disabled? I am trying to send an email using the code below but get the error message "popen has been disabled for security reasons". On checking with my host provider it has indeed been disabled and cannot be enabled on shared hosting. Does this make PHPMailer unusable for me?

        $mail = new PHPMailer();
        $mail->SetFrom('[email protected]', 'Byetunes');
        $mail->AddReplyTo($param['sender_email'], $param['sender_name']);
        $mail->AddAddress($receiverEmails[0]);

        $mail->isHTML(true);
        $mail->isSendmail(true);
        $mail->Subject  = $param['subject'];
        $mail->Body     = $message_body;

        $sendingStatus = $mail->send();

Solution

  • You only need popen because you're using isSendmail - why are you doing that?

    If you use isMail (the default, most likely to work on shared hosting) or isSMTP, you don't need popen.