Jump to content

Another newbie question with phpmailer and gmail


VTXmom

Recommended Posts

I have created a contact form that sends an email when the user clicks the send button on the form. It acts like it is sending but then eventually times out with this message, "Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:\xampp-win32-1.8.3-5-VC11\xampp\htdocs\pet-shop\class.smtp.php on line 338".

 

I have searched the forums and so far have not found any other posts on this. Can someone look at my php code and tell me if they see anything wrong?  I got the settings from the gmail example in the phpmailer folder.   This is for a class assignment, here is my php code:

<?php

  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  // here we use the php mail function
  // to send an email to:
  // you@yourdomain.com
  mail( "aughinbaughtestemail@gmail.com", "Contact Us",$message, "From: $email" );
?>

<?php
date_default_timezone_set('Etc/UTC');

require 'PHPMailerAutoLoad.php';

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->STMPDebug = 2;
$mail->Debugoutput = 'html';;
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "aughinbaughtestemail@gmail.com";
$mail->Password = "******";
$mail->From = $email;
$mail->setFrom('aughinbaughtestemail@gmail.com','First Last');
$mail->addReplyTo('aughinbaughtestemail@gmail.com', 'First Last');
$mail->AddAddress('aughinbaughtestemail@gmail.com', 'Andrea Aughinbaugh');
$mail->Subject = 'PHPMailer Gmail SMTP test';
$mail->AltBody = 'This is a plain-text message body';
$message = $_REQUEST['message'] ;
$mail->Body    = $message;
$mail->AltBody = $message;

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

Thanks for all the help I have been receiving with this project, I know I must look like a bit of a dummy.

 

I just noticed in the bottom left corner it says "waiting for localhost", don't know if that helps.

Edited by VTXmom
Link to comment
Share on other sites

Thank you for helping, that line does not appear in my php.ini file, do I need to add it, if so, does it go under mail function?

 

I need manage to get rid of the error by changing the host to localhost, but now I am getting an SMTP error. In looking around I also found that SMTP is deactivated in XAMPP and I can find no instructions on how to activate it. Can anyone tell me how to activate it?

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.