postfix配置smtp发送邮件参考

鉴客 发布于 2011/11/28 22:28
阅读 2K+
收藏 2
要配置一个postfix发邮件,需要以 xx@test.aslibra.com 发送邮件
同时提供smtp服务给局域网其它服务器提供发送邮件服务

安装好postfix后,可以参考如下配置文件(去掉注释内容):

/etc/postfix/main.cf
myhostname = test.aslibra.com
mydomain = test.aslibra.com
mynetworks = 192.168.1.0/24, 127.0.0.0/8
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myorigin = $myhostname
inet_interfaces = all
unknown_local_recipient_reject_code = 550
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
   PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
   xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES

PHP发送邮件可以使用phpmailer
include('libraries/class.phpmailer.php');

$mail = new PHPMailer();  
$mail->CharSet="UTF-8";
$mail->IsSMTP();                            // 经smtp发送  
$mail->Host     = $this->smtp_ip;           // SMTP 服务器  
$mail->SMTPAuth = false;          // 局域网不需要SMTP 认证  
$mail->From     = $from;  // 发信人  
$mail->FromName = $fromuser;        // 发信人别名  
$mail->Sender = $from;

$mail->AddAddress($to);  // 收信人  
if(isset($ccmail)){  
  $mail->AddCC($ccmail);  // cc收信人
}  
if(isset($bccmail)){  
  $mail->AddCC($bccmail);    // bcc收信人
}  

$mail->WordWrap = 50;  
$mail->IsHTML(true);                            // 以html方式发送  
$mail->Subject  = $title;                 // 邮件标题  
$mail->Body     = $content;                    // 邮件内空  

$mail->Send();

参考阅读:

1 带smtp认证的postfix配置
http://hi.baidu.com/jedibd/blog/item/7b73ab25a7b7e06d35a80f45.html
2 CentOS下(PostFix)SMTP服务器的构建
http://www.fuancn.cn/html/ServerSettings/Linux/CentOS/20084288.html
3 phpmailer,smtp发送邮件实例
http://blog.51yip.com/php/910.html/comment-page-1

原文出处:http://www.aslibra.com/blog/post/postfix_smtp_mail.php

加载中
返回顶部
顶部