标签: multipart-alternative

Javascript正则表达式:查找所有网址优化

这个问题是以下帖子的后续内容: Javascript正则表达式:查找<a>标签之外的所有网址 - 嵌套标签

我发现代码:

\b((https?|ftps?):\/\/[^"<\s]+)(?![^<>]*>|[^"]*?<\/a)
Run Code Online (Sandbox Code Playgroud)

相比单独执行它是极其低效的httpftp部分是这样的:

\b(https?:\/\/[^"<\s]+)(?![^<>]*>|[^"]*?<\/a)
Run Code Online (Sandbox Code Playgroud)

\b(ftps?:\/\/[^"<\s]+)(?![^<>]*>|[^"]*?<\/a)
Run Code Online (Sandbox Code Playgroud)

以下是regex101.com的示例:

但是,在我的一个HTML页面中,这些代码比较为85628步骤与7258 + 795步骤,这非常疯狂.

据我所知,使用(x | y)模式可以减少执行长度,但这可能是因为一个奇怪的原因.

任何帮助,将不胜感激.

html javascript regex hyperlink multipart-alternative

6
推荐指数
1
解决办法
105
查看次数

PHP mail()Multipart /替代HTML和纯文本电子邮件

我使用以下代码发送Multipart/Alternative HTML和纯文本电子邮件.这些电子邮件正在发送精美的内容,但其中一些邮件被垃圾邮件过滤器捕获.这是我正在使用的代码.

$notice_text = "This is a multi-part message in MIME format.";
$plain_text = "Some Plain Text Here\n\n";
$html_text = '<html><head><title>Sample HTML Email</title></head><body>';
$html_text .= '<p>Some text will go here.</p>';
$html_text .= '<p><img src="http://www.mydomain.com/img/offers.jpg" /></p>';
$html_text .= '<p>Can\'t see the images? <a href="http://www.mydomain.com/print_offer.php?promo=' . $promo_code . '">Click here</a></p>';
$html_text .= '</body></html>';

$semi_rand = md5(time());
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
$mime_boundary_header = chr(34) . $mime_boundary . chr(34);

$from = "Test Email <testemail@testemail.com>";
$subject = "Get Your Offers Here";

$body = "$notice_text

--$mime_boundary
Content-Type: …
Run Code Online (Sandbox Code Playgroud)

php email multipart-alternative

5
推荐指数
1
解决办法
1万
查看次数

我的Gmail收件箱中的非名字附件

在使用带有Multipart电子邮件的Rails ActionMailer时,我创建了两个:

approve_trade_email.html.erb

approve_trade_email.text.erb

我确实在我的邮件客户端(Mac OSX)中收到了一封HTML格式的电子邮件,但是在检查我的Gmail帐户中是否收到同一封电子邮件时,我得到了一个带有noname附件的空机身,里面有多部件?

救命?

为什么我要在Gmail中使用此功能?

谢谢

乔尔

这里是GMAIL中的非活动附件:

----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bc857_10583ff27b4e363c43191@joel-maranhaos-macbook-pro.local.mail>


Do not to forget to make a donation on our Site: /home/index?path_only=false


----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bd5fa_10583ff27b4e363c432cb@joel-maranhaos-macbook-pro.local.mail>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>  
<link href="/assets/powerplants.css" media="screen" rel="stylesheet" type="text/css" …
Run Code Online (Sandbox Code Playgroud)

gmail multipart actionmailer ruby-on-rails-3 multipart-alternative

5
推荐指数
1
解决办法
1828
查看次数

使用PHP邮件发送multipart/alternative()

所以我试图用PHP发送一个相当简单的HTML电子邮件.我花了最近三天试图找到一个好的解决方案,并认为我找到了一个,但是当我测试它时,它没有正确发送.我从我引用的其中一个教程中借用了这段代码.测试代码如下:

<?php
//define the receiver of the email
$to = 'myemail@gmail.com';
//define the subject of the email
$subject = 'Test HTML email'; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"".$random_hash."\""; 
//define the body of the …
Run Code Online (Sandbox Code Playgroud)

php html-email multipart-alternative

5
推荐指数
1
解决办法
3146
查看次数

使用Swift Mailer发送multipart/alternative邮件

我不能用Swift Mailer发送multipart/alternative(我没有找到任何引用,所以也许我不能使用这个函数),这是我的代码:

$file[1]=html_entity_decode($file[1]);
//Prepare plain/html body
foreach($rep as $find => $sost)
    $file[1]=str_replace($find,$sost,$file[1]);
//Prepare plain/text body
$plain=strip_tags(str_replace('&nbsp;',' ',str_replace('<br/>',"\n",$file[1])));
$boundary=uniqid('n_=_p');
//Prepare mail body                 
$body = "--".$boundary."\r\n";
$body .= "Content-type: text/plain;\r\ncharset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n";
$body .= $plain;
$body .= "\r\n--".$boundary."\r\n";
$body .= "Content-type: text/html;\r\ncharset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n";
$body .= "<html><body>".$file[1]."</body></html>";
$body .= "r\n--".$boundary ."--";
//Send Mail
$message = Swift_Message::newInstance();
$message->setFrom(array($stmp[2]=>$stmp[1]));
$message->setReplyTo(array($stmp[2]=>$stmp[1]));
$message->setSubject($file[0]);
$message->setContentType("multipart/alternative");  
$message->setBody($body);
$message->setTo($mail);
$message->setBoundary($boundary);

if($stmp[0]==0)
    $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -t');
else if($stmp[0]==1){
    if($stmp[5]==0)
        $transport = Swift_SmtpTransport::newInstance($stmp[2],$stmp[4]);
    else
        $transport = Swift_SmtpTransport::newInstance($stmp[2],$stmp[4],'ssl');

    if($stmp[6]==1){
        $transport->setUsername($stmp[7]);
        $transport->setPassword($stmp[8]);
    }
}

$mailer …
Run Code Online (Sandbox Code Playgroud)

php email swiftmailer multipart-alternative

3
推荐指数
1
解决办法
6103
查看次数