出于某种原因,“To”参数在Gmail和Outlook中的Mac上运行。但是,当我在Windows中尝试链接时,它们无法在任何浏览器和任何客户端中运行。是什么给了什么?
现在作为一个小背景,我正在使用一些JavaScript构建链接。以下是我的代码。也许我做错了。奇怪的是,这只是Windows中的问题而不依赖于浏览器或邮件客户端。
代码:
<div class="customsms-model-box email-modal share-modal sms-modal">
<div class="modal-title">Send a link via SMS</div>
<form id="email-box">
<div class="email-info">
Web access on phone is required to view the full list. Standard text message rates from your carrier will apply. You will be sending this SMS message through your e-mail program. We will build everything for you. You will just have to send it.
</div>
<div class="mobile-carrier">
<span class="carrier-label">Mobile carrier: </span>
<select name="email_to_email">
<option value='' selected="selected">Select one</option>
<?php print users_carrier_options(); ?>
</select>
</div>
<div class="recipient-phone">
<span class="recipients-phone">Recipient's phone: </span>
<input type="text" name="phone_number" value="" /><br>
<span class="subnote">Enter phone number including area code. Numbers only, no other characters.</span>
</div>
<div class="email-buttons">
<a href="#" class="orange-link send-mail" target="_blank">Send link</a>
<a href="#" class="simple-link cancel close">Cancel</a>
</div>
</form>
</div>
<div class="email_body" ref="<?php print $list->id; ?>">Follow the URL to see my items! <?php print $smsLink; ?></div>
<div class="email_subject" ref="<?php print $list->id; ?>">SOME COMPANY SUBJECT</div>
<script>
jQuery(document).ready(function($) {
var eBody = $('#modal-content .email_body').text();
var eSubject = $('#modal-content .email_subject').text();
var eTo = "";
var eFrom = "<?php print $user->mail; ?>";
update_email();
$('a.send-mail').click(function() {
if (eTo == '') {
alert("You must enter an email address!");
return false;
}
});
//Replace this with something for the SMS carrier emailTo stuff
$(".mobile-carrier select").change(function(){
if ($(this).val() != '') {
update_to(true);
}
});
$(".recipient-phone input").change(function(){
if ($(this).val() != '') {
update_to();
}
});
function update_to(calledBySelect) {
if (calledBySelect != true) {
calledBySelect = false;
}
var phone = $(".recipient-phone input").val().replace(/[^\d.]/g, ""); //Get the phone number and leave only digits
//A little validation
if (phone.length != 10 && !calledBySelect) {
alert('You must put in a 10 digit phone number.');
return false;
}
var carrier = $('.mobile-carrier select').val();//Gotta load the carrier domain
eTo = phone + '@' + carrier; //Build the email to address
update_email(); //Make sure all of this gets updated
}
function update_email() {
$('.email-buttons a.send-mail').attr( 'href', 'mailto:?subject=' + encodeURIComponent(eSubject) + '&body=' + encodeURIComponent(eBody) + '&to=' + encodeURIComponent(eTo) + '&from=' + encodeURIComponent(eFrom) );
}
});
</script>
答案 0 :(得分:2)
而不是设置to
参数设置最前面的电子邮件:
mailto:EMAIL_ADDRESS?Subject....
$('.email-buttons a.send-mail').attr( 'href', 'mailto:'+encodeURIComponent(eTo)+'?subject=' + encodeURIComponent(eSubject) + '&body=' + encodeURIComponent(eBody) + '&from=' + encodeURIComponent(eFrom) );