删除 Postfix 邮件队列中的特定邮件
Monday, 22. December 2008, 10:36:06
例:
# mailq | awk '/bad_address@bad_domain/ {print $1}' | tr -d '*' | xargs -n 1 postsuper -d
其中 bad_address@bad_domain 这个字符串根据实际情况修改。
这个命令用到了 awk,tr, xargs 这些命令,很有代表性,因此记录一下。
无不用其“极”
Monday, 22. December 2008, 10:36:06
Wednesday, 5. December 2007, 07:34:02
<?php
require_once 'Mail.php';
require_once 'Mail/mime.php';
/**
*
* 邮件发送或转发(可带附件)*
* @param $mail_info :邮件内容*
* @param $forward_to :转发地址*
* @return 发送结果*
* @author Jlake OU 2007/12/05
**/
function MAIL_forward($mail_info, $forward_to)
{
$mailObject = Mail::factory("mail");
$mimeObject = new Mail_Mime("\n");
$mimeObject->setTxtBody(mb_convert_encoding($mail_info['body'], "ISO-2022-JP", "auto"));
foreach($mail_info['attachment'] as $path) {
$mimeObject->addAttachment($path);
}
$bodyParam = array(
"head_charset" => "ISO-2022-JP",
"text_charset" => "ISO-2022-JP"
);
$body = $mimeObject -> get($bodyParam);
$addHeaders = array(
"To" => $mail_info['to'],
"From" => $mail_info['from'],
"Subject" => mb_encode_mimeheader($mail_info['subject'])
);
$headers = $mimeObject->headers($addHeaders);
return $mailObject->send($forward_to, $headers, $body);
}
//测试
$mail_info = array(
'from' => 'user@fromdomain.com',
'to' => 'user@todomain.com',
'subject' => 'Mail forward test',
'body' => 'This is a test',
'attachment' => array(
'/tmp/test1.jpg'
,'/tmp/test2.jpg'
)
);
MAIL_forward($mail_info, 'user@forwarddomain.com');
?>
Thursday, 25. October 2007, 06:49:51
diary: "|/usr/local/bin/php /***/****/diary.php"
|/usr/local/bin/php /***/****/diary.php
<?php
require_once 'Mail/mimeDecode.php';
// 取得邮件内容
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = file_get_contents("php://stdin");
$params['crlf'] = "\r\n";
$structure = Mail_mimeDecode::decode($params);
//取得发送邮件地址
if(preg_match("/<(.*)>/", $mail_from, $matches)) {
$mail_from = $matches[1];
}
//取得目标邮件地址
$mail_to = $structure->headers['to'];
if(preg_match("/<(.*)>/", $mail_to, $matches)) {
$mail_to = $matches[1];
}
// 取得邮件标题
$mail_subject = $structure->headers['subject'];
switch(strtolower($structure->ctype_primary)){
case "text": // 只有一个Part(文本邮件)
$mail_body = $structure->body;
break;
case "multipart": // 有多个Part(图片等)
foreach($structure->parts as $part){
switch(strtolower($part->ctype_primary)){
case "text": // 正文
$mail_body = $part->body;
break;
case "image": // 图片
//取得图片文件扩展名并转为小写
$type = strtolower($part->ctype_secondary);
//检查是否为JPEG格式(同样可以检查是否为GIF或者PNG格式)
if($type != "jpeg" and $type != "jpg"){
continue;
}
//把附件保存到文件
$file_mame = $part->ctype_parameters['name'];
$fp = fopen("/tmp/$file_mame", "w" );
$length = strlen( $part->body );
fwrite( $fp, $part->body, $length );
fclose( $fp );
break;
}
}
break;
default:
$mail_body = "";
}
/*
* 其他处理,如:把邮件地址、标题、正文、图片等信息保存到数据库
*/
?>
$ pear install -a Mail $ pear install -a Mail_MIME
mb_detect_order("ASCII, JIS, UTF-8, EUC-JP, SJIS");
$mail_subject = mb_convert_encoding($structure->headers['subject'], 'EUC-JP', 'auto');
Tuesday, 20. March 2007, 05:13:49
echo "Body" | mail -s "Subject" addr@some.domain
email="to@toaddress.com"
emailname="Test Mail"
messagebody="tmp.tmp"
from="from@fromaddress.com"
fromname="MailReport"
subject="Mail Report"
echo -e "To: \"${emailname}\" <${email}>\nFrom: \"${fromname}\" <${from}>\nSubject: ${subject}\n\n`cat ${messagebody}`" | /usr/sbin/sendmail -t
echo "<h1>你好</h1><p style=\"color:red; background-color:gray; height:10em;\">html 邮件测试</p>" | email --html --smtp-user 发送邮件所用的帐号 --smtp-pass 发送邮件所用的密码 --subject "这里是标题" --attach 文件1.zip,文件2.jpg,文件3.tar --cc 抄送到邮件地址 -bcc 暗送到邮件地址 收件人邮件地址
Thursday, 2. February 2006, 11:38:16
Sub SendMailCDONTS(aTo, Subject, TextBody, aFrom)
Const CdoBodyFormatText = 1
Const CdoBodyFormatHTML = 0
Const CdoMailFormatMime = 0
Const CdoMailFormatText = 1
Dim Message 'As New cdonts.NewMail
'Create CDO message object
Set Message = CreateObject("CDONTS.NewMail")
With Message
'Set email adress, subject And body
.To = aTo
.Subject = Subject
.Body = TextBody
'set mail And body format
.MailFormat = CdoMailFormatText
.BodyFormat = CdoBodyFormatText
'Set sender address If specified.
If Len(aFrom) > 0 Then .From = aFrom
'Send the message
.Send
End With
End Sub
Sub SendMailCDO(aTo, Subject, TextBody, aFrom)
Const cdoOutlookExvbsss = 2
Const cdoIIS = 1
Dim Message 'As New CDO.Message
'Create CDO message object
Set Message = CreateObject("CDO.Message")
With Message
'Load IIS configuration
.Configuration.Load cdoIIS
'Set email adress, subject And body
.To = aTo
.Subject = Subject
.TextBody = TextBody
'Set sender address If specified.
If Len(aFrom) > 0 Then .From = aFrom
'Send the message
.Send
End With
End Sub
Sub SendMailCDOCacheConf(aTo, Subject, TextBody, aFrom)
'cached configuration
Dim Conf ' As New CDO.Configuration
If IsEmpty(Conf) Then
Const cdoOutlookExvbsss = 2
Const cdoIIS = 1
Set Conf = CreateObject("CDO.Configuration")
Conf.Load cdoIIS
End If
Dim Message 'As New CDO.Message
'Create CDO message object
Set Message = CreateObject("CDO.Message")
With Message
'Set cached configuration
Set .Configuration = Conf
'Set email adress, subject And body
.To = aTo
.Subject = Subject
.TextBody = TextBody
'Set sender address If specified.
If Len(aFrom) > 0 Then .From = aFrom
'Send the message
.Send
End With
End Sub
Sub SendMailCDOCacheConf(aTo, Subject, TextBody, aFrom)
'cached configuration
Dim Conf 'As New CDO.Configuration
If IsEmpty(Conf) Then
Const cdoSendUsingPort = 2
Set Conf = CreateObject("CDO.Configuration")
With Conf.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your.smtp.server"
.Update
End With
End If
Dim Message 'As New CDO.Message
'Create CDO message object
Set Message = CreateObject("CDO.Message")
With Message
'Set cached configuration
Set .Configuration = Conf
'Set email adress, subject And body
.To = aTo
.Subject = Subject
.TextBody = TextBody
'Set sender address If specified.
If Len(aFrom) > 0 Then .From = aFrom
'Send the message
.Send
End With
End Sub
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)
'Create an Outlook object
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
'You can display the message To debug And see state
'.Display
.Subject = Subject
.Body = TextBody
'Set destination email address
.Recipients.Add (aTo)
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message
.Send
End With
End Sub
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
| ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
LinuxSir
Linux中坚站
为Linux工程师提供技术动力
打造中国最大的UNIX/LINIX资讯站
My mirror, my window, the bridge connecting you and I.
关注:php,mysql,ajax ,linux, js,开源
有用的Opera菜单
なにもあたらしくない
By Adam Li
By Satoru Watanabe
by singway
by 摸鱼儿
by Somh
by 法师
by yumumao
Maybe I was a Bird in another Life !
投放广告挣美元,可用PayPal接收付款
免费网页模板
数据表格样式收集