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
https://forums.phpfreaks.com/topic/201181-phpmailer-help/
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
https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1055974
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
https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1056040
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
https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1056048
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.