Jump to content

PHPMailer help


ChaosKnight

Recommended Posts

I decided to include PHPMailer for use with the outgoing e-mails, but for some reason when I submit the form, the page include just disappears and no mail gets sent... Here is the code that I tried:

      require("class.phpmailer.php");

      $mailer = new PHPMailer();

      $mailer->IsSMTP();
      $mailer->Host = $host;
      $mailer->SMTPAuth = true;
      $mailer->Username = $user;
      $mailer->Password = $password;
      
      $mailer->From = $address_from;
      $mailer->AddAddress($address_to);

      $mailer->WordWrap = 50;

      $mailer->IsHTML(true);

      $mailer->Subject = $subject;
      $mailer->Body = $message;

      if($mailer->Send()){
        echo "<h3>The message was sent successfully...</h3>";
      }else{
        echo "<h3>The message could not be sent...</h3>" . $mailer->ErrorInfo;
        exit;
      }

 

Everythng is on the same page as the form, and the other code works fine, it's only the e-mail part...

 

Any help will be greatly appreciated

 

Thanks

Link to comment
Share on other sites

What is your

 

$mailer->Port equal to on the server?

 

echo the user/password and make sure they are correct.

 

IsHTML(true) I think is depreciated.

use

$mailer->MsgHTML($body);

instead of ->Body

 

also

$mailer->AltBody="Non html version";

 

And try changing:

$mailer->AddAddress($address_to);

to

$mailer->AddAddress($address_to, "Recipient");

 

To make sure you don't need a name to call the method.

Link to comment
Share on other sites

I'll quickly try those, but I discovered that even a simple script like the one below, stops executing completely... Is there some way to make sure that the PHP script "sees" class.phpmailer.php? I placed it in the same directory as the contact.php page though... And the webhost told me that the port is set to the default

<?php
  require("class.phpmailer.php");
  $mail = new PHPMailer();
  echo "Hello World";
?>

 

Link to comment
Share on other sites

Okay so I used the file_exists function, and it returned that it found the file, then I commented out the $mail = new PHPMailer(); command  and left the required, and it still executed the code after the require command. But when I uncommented the $mail = new PHPMailer(); command, the code stopped executing again... Any ideas on what could be wrong? Any help will be greatly appreciated... It seems as if the problem is in the object...

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

Are you sure you're using the right PHP version? Make sure it supports Objects, at least 5.0:

 

In a clean *.php file type the following:

 

<?php phpinfo(); ?>

 

...and take a look at the output checking for the PHP version.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.