Answer the question
In order to leave comments, you need to log in
Why doesn't SMTP mail sending work?
I want to make sure that mail is sent from my email to Yandex mail, to which my domain is linked, I use the pear mail library.
require_once("Mail-1.4.1/Mail.php");
$from = "Sandra Sender <[email protected]>";
$to = 'Sandra Sender <email>';
$subject = "Test";
$body = '<p>Test</p>';
$host = "smtp.yandex.ru";
$username = "[email protected]";
$password = 'pass';
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if ( PEAR::isError($mail) ) {
echo('<p>Error sending mail:<br/>'.$mail->getMessage().'</p>');
} else {
echo('<p>Message sent.</p>');
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question