i have phpmailer installed on my localhost and i have the following configuration
$to_name = "Thomas Anderson";
$to = "t_andersons@hotmail.com";
$subject = "Mail Test at ".strftime("%T", time());
$message = "This is a test.";
$message = $message;
$from_name = "Thomas Anderson";
$from = "t_andersons@hotmail.com";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "example@gmail.com";
$mail->Password = "password";
$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = $message;
$result = $mail->Send();
echo $result ? 'Sent' : 'Error';
this works fine
on a different server, i have typed in the same information at admin/settings/smtp and i'm getting the error
"The configuration options have been saved.A test e-mail has been sent to t_andersons@hotmail.com. You may want to check the logs for any error messages." and
"Unable to send e-mail. Please contact the site administrator if the problem persists."
in admin/reports/dblog i'm getting
Type mail
Date Monday, September 12, 2011 - 14:59
User tandersons
Location http://domain.net/admin/settings/smtp
Referrer http://domain.net/admin/settings/smtp
Message Error sending e-mail (from example@gmail.com to t_andersons@hotmail.com).
Severity error
Hostname 70.25.75.104
Operations
i have also created a test page under sites/all/themes/yghhzen/test_page.php and executed the same code above and i'm getting a blank screen. i have also tried
$to = 't_andersons@hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: t_andersons@hotmail.com' . "\r\n" .
'Reply-To: t_andersons@hotmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$rc = mail($to, $subject, $message, $headers);
if ($rc) {
print "Mail successfully sent!<br>";
}
else {
print "Failed to send mail<br>";
}
and the page outputs "Failed to send mail"
i don't know if it's the server configuration or some configuration in drupal but i can't get neither mail nor phpmailer to work. i will be greatful if someone can help me with this
Comments
Comment #1
josesanmartin commentedmail() function is PHP's and smtp.module has nothing to do with it. It will work or not depending on your server configurations.
For phpmailer, check if your server is capable of establishing connections to gmail in the desired port. It might be configured to block certain types of traffic.
Comment #2
wundo commentedClosing very old (dead) issues, if you think this is still relevant please re-open.