1. 简介
用脚本发送邮件
2. 发送
//setFrom函数中的邮箱必须与smtp服务器登录名相同,对于163是这样的,不然会发送失败
$mail = new Zend_Mail('UTF-8');
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom(, 'Some Sender');
$mail->addTo(, 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($mailTransport);
3. 发送服务器
3.1 sendmail
3.2 smtp
163邮箱设置
===
$config = array(
'auth' => 'login',
'username' => 'abc',
'password' => '11111111',
'port' => 25,
//'ssl' => 'ssl',
);
$mailTransport = new Zend_Mail_Transport_Smtp('smtp.163.com', $config);
Zend_Mail::setDefaultTransport($mailTransport); //设置以后send()可以不用参数
4. 读取邮件
public function getmailAction(){
$mail = new Zend_Mail_Storage_Pop3(array('host' => 'pop3.163.com',
'user' => 'abc',
'password' => '11111111'));
echo $mail->countMessages() . " messages found
";
foreach ($mail as $message) {
echo "Mail from '{$message->from}': {$message->subject}
";
}
//$this->renderScript("index.phtml");
}
阅读(493) | 评论(0) | 转发(0) |