Reputation: 35
I have been doing this for hours and can't get it to work, many comments in the tutorial said it works like a charm but I can't really make this work.
I have done all the steps here http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/ and read all the comments with problems other users encountered and also used the solutions replied.
What I see on the apache error log is this
[Tue Nov 27 05:19:47 2012] [notice] Parent: Created child process 4120
[Tue Nov 27 05:19:47 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Child process is running
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Acquired the start mutex.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting 64 worker threads.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.
I also have tried it on my other computer and it has the same error log. I have disabled my firewall and also critically followed the steps on the tutorial.
Upvotes: 3
Views: 1227
Reputation: 570
Sorry for the previous answer. Thanks everyone for your suggestions to improve my answer. Here is my answer: The phpmailer has a file called class.phpmailer.php. Then in the function smtpmailer($to, $from, $from_name, $subject, $body)
the code goes as follows:
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'gmailusername';
$mail->Password = 'gmailpassword';
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->IsHTML(True);
$mail->Body=$body;
//$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
Then just call the function where ever you want as:
smtpmailer($to, $from, $headers, $subject, $message);
Oh and prior to this make sure php_openssl extension is enabled.
I hope this answer of mine was helpful. :)
Upvotes: 5