SS版本:3.3.2
我正在完成一个已经存在的项目。基本上,每个配置文件都有一个“发送电子邮件给我们”链接。单击该按钮,填写详细信息,然后将电子邮件发送给用户。电子邮件变量未显示成员电子邮件。联系电子邮件正在显示。
我将向您展示PHP的联系表单和电子邮件模板。
page.php文件
function profilecontactformajax() {
$formdata = array(
'ProfileID' => isset($_REQUEST['ProfileID'])?$_REQUEST['ProfileID']:'',
'Subject' => isset($_REQUEST['Subject'])?$_REQUEST['Subject']:'',
'Email' => isset($_REQUEST['Email'])?$_REQUEST['Email']:'',
'Content' => isset($_REQUEST['Content'])?$_REQUEST['Content']:'',
'EmailLayout' => 'ProfileContact'
);
$formdata['HeaderFontStyles'] = 'font-family: Arial, Helvetica, sans-serif; font-weight: normal;font-size:16px; color:#e60080; line-height:18px';
$formdata['DefaultFontStyles'] = 'font-family: Arial, Helvetica, sans-serif; font-weight: normal;font-size:12px; color:#6c6e6d; line-height:15px';
$formdata['SmallFontStyles'] = 'font-family: Arial, Helvetica, sans-serif; font-weight: normal;font-size:10px; color:#e60080;';
$formdata['FooterFontStyles'] = 'font-family: Arial, Helvetica, sans-serif; font-weight: normal;font-size:12px; color:#6c6e6d;';
$profile = DataList::create('Profile')->filter(array('ID' => $formdata['ProfileID']))->first();
if ($profile) {
//save data
$o = new ProfileContactMessage();
$o->Subject = $formdata['Subject'];
$o->Email = $formdata['Email'];
$o->Content = $formdata['Content'];
$o->ProfileID = $formdata['ProfileID'];
$o->write();
$formdata['URLSegment'] = $profile->URLSegment;
//get member details
$member = DataList::create('Member')->filter(array('ID' => $profile->CreatorMemberID))->first();
if ($member) {
$formdata['FirstName'] = $member->FirstName;
$formdata['MemberEmail'] = $member->Email;
}
$to = $profile->Email;
$from = 'noreply@designersplace.com.au';
$subject = $formdata['Subject'];
$email = new Email($from, $to, $subject);
$email->setTemplate('BaseEmailTemplate');
$email->populateTemplate($formdata);
$email->send();
}
return $this->customise($formdata)->renderWith('Page_profilecontactformajax');
}
BaseEmailTemplate.ss
<% if EmailLayout = 'ProfileContact' %>
<table cellpadding="0" cellspacing="0">
<tr>
<td width="350" valign="top" style="text-align:left;">
<p style="$DefaultFontStyles">Dear $Name</p>
<p style="$DefaultFontStyles">Someone has sent you a message via your Designers Place profile.</p>
<p style="$DefaultFontStyles"><strong>Subject:</strong><br>$Subject</p>
<p style="$DefaultFontStyles"><strong>Email:</strong><br>$Email</p>
<p style="$DefaultFontStyles"><strong>Comments:</strong><br>$Content</p>
<p style="$DefaultFontStyles">Warm Regards, </p>
<p style="$DefaultFontStyles">Designers Place Support Team. </p>
</td>
<td width="40"><img src="{$BaseHref}{$ThemeDir}/images/email/trans.gif" width="40" height="40" border="0"></td>
<td width="210" valign="top" style="text-align:left;">
<p style="$DefaultFontStyles"><strong>LOGIN DETAILS</strong></p>
<p style="$DefaultFontStyles">YOUR USERNAME:<br>$MemberEmail</p>
<p style="$DefaultFontStyles">YOUR PASSWORD:<br>******</p>
<p><a href="{$BaseHref}Security/login" target="_blank"><img src="{$BaseHref}{$ThemeDir}/images/email/login-now.jpg" width="210" height="43" border="0" class="image_fix"></a></p>
<p style="$DefaultFontStyles">VIEW YOUR PROFILE:<br><a href="{$BaseHref}{$URLSegment}" target="_blank">$URLSegment</a></p>
</td>
</tr>
</table>
<% end_if %>