I can't get phpmailer to work with MAMP (Free version). I've tried some suggestions from others for what worked with them but I've had no luck.
These are what I've tried so far: 1) Tried to use regular mail function from php using this - http://www.blog.tripleroi.com/2012/05/solvedenabling-sendmail-on-localhost.html
2) Enabled postfix following these post instructions - http://benjaminrojas.net/configuring-postfix-to-send-mail-from-mac-os-x-mountain-lion/ (Been getting "Undelivered Mail Returned to Sender")
I've just used generic scripts to tests and it keeps failing (but message says "success" or "Message has been sent").
Script 1:
$to = '<user>@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: <user>@yahoo.com' . "\r\n" .
'Reply-To: <user>@yahoo.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$retval = mail($to, $subject, $message, $headers);
if($retval !== true) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Script 2:
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 2; // Enable verbose debug output
echo "<pre>";
$mail->isSMTP(); // Set mailer to use SMTP
echo "</pre>";
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '<user>@yahoo.com'; // SMTP username
$mail->Password = '<password>'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('<user>@yahoo.com', 'Mailer');
$mail->addAddress('<user1>@yahoo.com', 'Joe User'); // Add a recipient
$mail->addAddress('<user2>@live.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$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';
}