F
F
Frendy2019-08-16 15:50:41
PHP
Frendy, 2019-08-16 15:50:41

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

1 answer(s)
T
t_q_l, 2019-08-16
@Frendy

outgoing mail:

mail server address - smtp.yandex.ru
connection security - SSL
port - 465

$host = "ssl://smtp.yandex.ru";
$port = "465";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question