引用: |
[root@server~/]# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 server.domain.com.br ESMTP Postfix (2.1.0) MAIL FROM: [email protected] 250 Ok RCPT TO: [email protected] 250 Ok DATA 354 End data with <CR><LF>.<CR><LF> teste . 250 Ok: queued as 7B41F4665A QUIT 221 Bye Connection closed by foreign host. 注:以上来自netkiller的postfix文档,偷懒,直接用现成的。 |
引用: |
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 server.domain.com.br ESMTP Postfix (2.1.0) |
引用: |
DATA 354 End data with <CR><LF>.<CR><LF> teste . |
代码: |
<?php require_once 'Mail.php'; $conf['mail'] = array( 'host' => 'xx.xx.xx.xx', //smtp服务器地址,可以用ip地址或者域名 'auth' => true, //true表示smtp服务器需要验证,false代码不需要 'username' => 'tester', //用户名 'password' => 'retset' //密码 ); /*** * 使用$headers数组,可以定义邮件头的内容,比如使用$headers['Reply-To']可以定义回复地址 * 通过这种方式,可以很方便的定制待发送邮件的邮件头 ***/ $headers['From'] = '[email protected]'; //发信地址 $headers['To'] = '[email protected]'; //收信地址 $headers['Subject'] = 'test mail send by php'; //邮件标题 $mail_object = &Mail::factory('smtp', $conf['mail']); $body = <<< MSG //邮件正文 hello world!!! MSG; $mail_res = $mail_object->send($headers['To'], $headers, $body); //发送 if( Mail::isError($mail_res) ){ //检测错误 die($mail_res->getMessage()); } ?> |