Method for implementing SMTP sending mail in PEAR

xiaoxiao2021-03-06  43

REQUIRE_ONCE 'mail.php';

$ conf ['Mail'] = array (

'host' => 'xx.xx.xx.xx', // SMTP server address, you can use IP addresses or domain names

'auth' => true, // true means that the SMTP server needs to be verified, the FALSE code does not need

'username' => 'Tester', // username

'password' => 'RetSet' // password

);

/ ***

* Use the $ headers array, you can define the content of the email header, such as using $ headers ['reply-to'] can define a reply address

* In this way, it can be very convenient to customize the mail header to be sent.

*** /

$ Headers ['from'] = 'Tester@domain.com'; // Sending address

$ Headers ['to'] = 'tester@domain.com'; // Receive address

$ Headers ['Subject'] = 'Test Mail Send By PHP'; // Email Title

$ mail_Object = & mail :: Factory ('SMTP', $ conf ['mail']);

$ body = <<< msg // message body

Hello World !!!

MSG;

$ mail_res = $ mail_object-> send ($ Headers ['To'], $ Headers, $ Body); // Send

IF (Mail :: ISERROR ($ mail_res)) {// detection error

DIE ($ mail_res-> getMessage ());

}

?>

转载请注明原文地址:https://www.9cbs.com/read-67084.html

New Post(0)