Mail 总结
时间:2010-03-31 来源:bing_fox
1. 简介
用脚本发送邮件
2. 发送
//setFrom函数中的邮箱必须与smtp服务器登录名相同,对于163是这样的,不然会发送失败
$mail = new Zend_Mail('UTF-8');
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', '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<br>";
foreach ($mail as $message) {
echo "Mail from '{$message->from}': {$message->subject}<br>";
}
//$this->renderScript("index.phtml");
}
用脚本发送邮件
2. 发送
//setFrom函数中的邮箱必须与smtp服务器登录名相同,对于163是这样的,不然会发送失败
$mail = new Zend_Mail('UTF-8');
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', '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<br>";
foreach ($mail as $message) {
echo "Mail from '{$message->from}': {$message->subject}<br>";
}
//$this->renderScript("index.phtml");
}
相关阅读 更多 +