While I am making contact form, so I want to test things in localhost before it goes live. I am on mac Yosemite and using Xampp, how can I configure the xampp for sending mail?
XAMPP includes Mercury for sending emails. However, rather than using the PHP mail() function you could use PHPMailer to send your emails which would mean you don’t need Mercury. It would also be a better test of your contact form as it would be using exactly the same mail transport.
I have installed the phpmailer and testing it using their default code but I am getting the error
Warning: require(PHPMailer/PHPMailerAutoload.php): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/ProjectP/index.php on line 2
Fatal error: require(): Failed opening required 'PHPMailer/PHPMailerAutoload.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/ProjectP/index.php on line 2
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
require 'PHPMailer/PHPMailerAutoload.php';
assumes you have put PHPMailerAutoload.php and the other files you need (class.phpmailer.php and class.smtp.php) in a sub-directory named PHPMailer.
If you have put them in a different directory you need to change the path n the require statement.
Solved, the actual path is correct, but I have to set the folder permission Everyone to Access everything.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.