我想使用Ruby Net :: SMTP发送电子邮件.例程
send_message( msgstr, from_addr, *to_addrs )
Run Code Online (Sandbox Code Playgroud)
在我的代码中发送电子邮件效果很好,但是从这个API中不清楚如何将电子邮件发送到需要盲目复制的人员列表(密送:).
我错过了什么,或者用Net :: SMTP是不可能的?
我尝试通过IMAP将草稿电子邮件存储到MS Exchange上运行的文件夹中.一切都还可以,但Bcc收件人不会显示在服务器上存储的草稿邮件中.如果我使用MS Outlook发送密件抄送收件人也不会收到电子邮件.如果我在将消息存储到服务器后用Python读回消息,我可以在草稿中看到密件抄送.
以下Python代码重现此行为:
import imaplib
import time
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
message = MIMEMultipart()
message['Subject'] = 'Test Draft'
message['From'] = 'test@test.net'
message['to'] = 'test@test.com'
message['cc'] = 'testcc@test.com'
message['bcc'] = 'testbcc@test.com'
message.attach(MIMEText('This is a test.\n'))
server= imaplib.IMAP4('the.ser.ver.ip')
server.login('test', 'test')
server.append("Drafts"
,'\Draft'
,imaplib.Time2Internaldate(time.time())
,str(message))
server.logout()
Run Code Online (Sandbox Code Playgroud)
如果我运行此代码,草稿将存储到DraftExchange Server上的文件夹中.但是,如果我使用MS Outlook查看草稿,它不包括bccrecipient(message['bcc'] = 'testbcc@test.com').Message,to,from,ccOK,没有错误.
如果我从Exchange文件夹下载已包含密件抄送的草稿,我也可以看到密件抄送.只有上传对我不起作用.
任何帮助非常感谢.谢谢.顺便说一下,MAPI不是一个选择.
更新:谢谢.X-Receiver不适合我.至于在Outlook中使用IMAP-Folder,我得到了一个有趣的结果.如果我通过Outlook中的IMAP文件夹访问草稿,我会看到密件抄送.但是,如果我通过MAPI文件夹访问它,我看不到它.会发挥一点点.
结论:感谢您的投入.实际上,代码工作得很好.请参阅下面的我找到的答案.
我插入代码ItemSend并保存了ThisOutlookSession模块.它工作一次,不再有效.它保存为VBAproject.OTM,并在重新启动Outlook后打开模块时仍然存在.
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
''# #### USER OPTIONS ####
''# address for Bcc -- must be SMTP address or resolvable
''# to a name in the address book
strBcc = "someone@somewhere.dom"
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " …Run Code Online (Sandbox Code Playgroud) 我想使用Mandrill发送消息,我需要以下代码来做到这一点:
将相同的消息发送给所有收件人,而没有对方,每个人都看到另一个收件人的地址。
我使用以下代码:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
string[] toResult = to.Split(new Char[] { ';' });
foreach (string s in toResult)
{
if (s != null && !s.Trim().Equals("") && !string.IsNullOrEmpty(s))
{
message.Bcc.Add(s);
}
}
if (!cc.Equals(""))
{
string[] ccResult = cc.Split(new Char[] { ';' });
foreach (string s in ccResult)
{
message.CC.Add(s);
}
}
if (!cci.Equals(""))
{
string[] cciResult = cci.Split(new Char[] { ';' });
foreach (string s in cciResult)
{
message.Bcc.Add(s);
}
}
message.Subject = subject;
message.From = new …Run Code Online (Sandbox Code Playgroud) 我正在使用“System.Net.Mail”在 C# 中的 Intranet 系统上发送电子邮件
Send() 方法非常慢,我不明白为什么。
调试后,我删除了 BCC 调用:(MM 是 MailMessage() 和 Item,字符串电子邮件地址):
MM.Bcc.Add(new MailAddress(Item));
Run Code Online (Sandbox Code Playgroud)
在我评论这一行之前,一封电子邮件大约花了 30 或 40 秒。现在,大约有2秒。为什么?
对此有解释吗?我可以添加“收件人”和“抄送”,而不会出现性能问题。但不是“密件抄送”。
我正在尝试将密件抄送添加到 woocommerce / wp 发送的每封邮件中。我尝试使用在网络和 Stackoverflow 上找到的不同解决方案,并将片段添加到我正在使用的主题的functions.php中:
add_filter( 'woocommerce_email_headers', 'add_bcc_to_wc_admin_new_order', 10, 3 );
function add_bcc_to_wc_admin_new_order( $headers = '', $id = '', $wc_email = array() ) {
if ( $id == 'new_order' ) {
$headers .= "Bcc: my@mail.net\r\n";
}
return $headers;
}
Run Code Online (Sandbox Code Playgroud)
和
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);
function add_bcc_all_emails($headers, $object) {
$headers = array();
$headers[] = 'Bcc: my@mail.net';
$headers[] = 'Content-Type: text/html';
return $headers;
}
Run Code Online (Sandbox Code Playgroud)
和
add_filter('wp_mail','custom_mails', 10,1);
function custom_mails($args){
$bcc_email = sanitize_email('my@mail.net');
if (is_array($args['headers'])){
$args['headers'][] = 'Bcc: '.$bcc_email ; …Run Code Online (Sandbox Code Playgroud) 我从网站复制了PEAR邮件的代码,然后输入我的数据.有用.它发送邮件,但是,我想使用密件抄送发送给很多人并保持他们的地址匿名,它将发送给$收件人,但不是$ bcc.
代码:
<?php
$message = "yay email!";
require_once("Mail.php");
$from = 'myaddress@mysite.com ';
$to = "anadress@gmail.com";
$bcc = "thepeopleimemailing@yaddayadda.com";
$subject = " test";
$body = $message;
$host = "smtp.mysite.com";
$username = "myusername";
$password = "mypassword";
$headers = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Bcc' => $bcc,
'Subject' => $subject
);
$recipients = $to;
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password,
'port' => '25'
)
);
$mail = …Run Code Online (Sandbox Code Playgroud) 我使用下面的PHP代码发送电子邮件到一个地址和密送2其他地址.它向收件人发送罚款,但我只能将其发送到2个密件抄送地址之一.(请参阅代码中的注释,我尝试过)
奇怪的是,$结果又回来了3所以它似乎试图发送第二封密封电子邮件,但它永远不会通过.
<?php
$tracker='tracking@pnrbuilder.com';
$subject = $_POST['subject'];
$sender = $_POST['sender'];
$toEmail=$_POST['toEmail'];
$passedInEmail=stripslashes($_POST['message']);
$passedInEmail=preg_replace('/ /',' ',$passedInEmail);
require_once('swiftLib/simple_html_dom.php');
require_once('swiftLib/swift_required.php');
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
// Create the message
$message = Swift_Message::newInstance();
//turn the meesage into an object using simple_html_dom
//so we can iterate through and embed each image
$content = str_get_html($passedInEmail);
// Retrieve all img src tags and replace them with embedded images
foreach($content->find('img') as $e)
{
if($e->src != "")
{
$value = $e->src;
$newValue = $message->embed(Swift_Image::fromPath($value));
$e->src = $newValue;
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用PHPMailer来构建电子邮件.我只使用PHPMailer进行MIME消息格式化,而不是发送.
然后我从PHPMailer对象中提取原始消息,然后将其传递给Gmail API进行处理.
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
$mail->IsHTML(true);
//Disable SMTP debugging
// 0 = off (for production use)
$mail->SMTPDebug = 0;
//Set who the message is to be sent from
$mail->setFrom("fromaddress@domain.com", "From Name");
//Set an alternative reply-to address
$mail->addReplyTo("replyaddress@domain.com", "Reply Name");
//Set to address
$mail->addAddress("address@domain.com", "Some Name");
//Set CC address
$mail->addCC("ccaddress@ccdomain.com", "Some CC Name");
//Set BCC address
$mail->addBCC("bccaddress@ccdomain.com", "Some BCC Name");
//Set the subject line
$mail->Subject = "Test message"; …Run Code Online (Sandbox Code Playgroud) 我在 Laravel 中有邮件发送功能
public static function Compose($to,$cc,$bcc,$subject,$body)
{
// return $to;
try
{
$data = [
'body' => $body
];
if(env('APP_ENV') == "local")
{
$email["subject"] = $subject;
$email["to"] = $to;
$email["cc"] = $cc;
$email["bcc"] = $bcc;
Mail::send('email.composeMail', $data, function ($message) use ($email) {
$message
->subject($email["subject"])
->to($email["to"]);
->cc($email["cc"]);
->bcc($email["bcc"]);
});
}
else
{
$email["subject"] = $subject;
$email["to"] = $to;
$email["cc"] = $cc;
$email["bcc"] = $bcc;
Mail::send('email.composeMail', $data, function ($message) use ($email) {
$message
->subject($email["subject"])
->to($email["to"]);
->cc($email["cc"]);
->bcc($email["bcc"]);
});
}
}
catch …Run Code Online (Sandbox Code Playgroud) bcc ×10
email ×6
php ×4
c# ×2
smtpclient ×2
cc ×1
events ×1
gmail ×1
imap ×1
laravel-5.1 ×1
mandrill ×1
mime ×1
outlook-vba ×1
pear ×1
performance ×1
phpmailer ×1
python ×1
ruby ×1
sendmail ×1
swiftmailer ×1
vba ×1
woocommerce ×1
wordpress ×1