ChaosKnight Posted May 9, 2010 Share Posted May 9, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/ Share on other sites More sharing options...
andrewgauger Posted May 10, 2010 Share Posted May 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1055974 Share on other sites More sharing options...
ChaosKnight Posted May 10, 2010 Author Share Posted May 10, 2010 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1056040 Share on other sites More sharing options...
ChaosKnight Posted May 10, 2010 Author Share Posted May 10, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1056048 Share on other sites More sharing options...
andrewgauger Posted May 10, 2010 Share Posted May 10, 2010 Verify the include file's includes are working. Also are you using: ini_set('display_errors', 1); It should tell you what is going on better than I can. Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1056099 Share on other sites More sharing options...
mxcnlink Posted May 21, 2010 Share Posted May 21, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1061460 Share on other sites More sharing options...
andrewgauger Posted May 21, 2010 Share Posted May 21, 2010 I assume this is related to: http://www.phpfreaks.com/forums/index.php/topic,297487.msg1411483.html#msg1411483 And solved. Quote Link to comment https://forums.phpfreaks.com/topic/201181-phpmailer-help/#findComment-1061474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.