Sending email using PHPMailer

Discussion in 'General troubleshooting' started by ever1, Jul 5, 2015.

  1. I am trying to send email messages using PHPMailer but it is failing silently.
    Has anyone used PHPMailer in Everleap successfully?
    Here is the test code:
    <html>
    <head><title>Test email via php</title></head>
    <body>
    <?php
    require_once "class.phpmailer.php";
    $from = "[email protected]";
    $to = "[email protected]";
    $subject = "This is a test email sent via php";
    $body = "This is a test email";
    $host = "smxx.internetmailserver.net";
    $username = "[email protected]";
    $password = "***";
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Host = $host;
    $mail->Username = $username;
    $mail->Password = $password;
    $mail->SetFrom($from, "Me");
    $mail->Subject = $subject;
    $mail->AltBody = $body;
    $mail->AddReplyTo($from,"Me");
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, "Recipient name");
    $mail->SMTPDebug = 4;
    echo "before";
    if(!$mail->Send()) {
    echo $mail->ErrorInfo;
    throw new Exception($mail->ErrorInfo);
    };
    echo "after";
    ?>
    </body>
    </html>
     
  2. Frankc

    Frankc Everleap staff

    Try enable display_error.

    • Create a file named .user.ini
    • put this line in "display_error=True" (without the quote)
    • upload the file to the site root.
    • restart the web application in the control panel
    Post the real error.
     
  3. I am having a similar problem with phpmailer.php. When posting the contact form I get:
    posting.... Warning: require_once(class.phpmailer.php): failed to open stream: No such file or directory in C:\home\site\wwwroot\Brochure.php on line 47 Fatal error: require_once(): Failed opening required 'class.phpmailer.php' (include_path='.;C:\php\pear') in C:\home\site\wwwroot\Brochure.php on line 47

    I also tried this with just mail.php instead of class.phpmailer.php as in the example above.
    Here is the code:

    $subject = "Brochure Request";
    /* change this to Pierre's email when tested*/
    $to = "Recipient <[email protected]>";
    /* Send the message using everleap mail() function */
    require_once "class.phpmailer.php";
    $from = "Sender <[email protected]>";
    $host = "mail.stocksearchintl.com";
    $username = "[email protected]";
    $password = "[redacted]"
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $message);echo "mail sent";
     

Share This Page