我刚收到上一个问题的答案:LINK
除了这个答案,我还有一个新的挑战。
我的mailform受form.lib.php文件支持,其中定义了mailsubject并将其打印到邮件中。
define( 'PHPFMG_SUBJECT' , "" );
function sendFormMail( $form_mail, $sFileName = "" )
{
$to = filterEmail(PHPFMG_TO) ;
$cc = filterEmail(PHPFMG_CC) ;
$bcc = filterEmail(PHPFMG_BCC) ;
};
$subject = PHPFMG_SUBJECT ;
我们在上一个主题中提取的空缺编号应该打印为邮件主题,因此我的crm系统正在使用它来注册响应。
我怎样才能实现这一目标?
答案 0 :(得分:0)
如果我正在读你当前的问题。使用上一个问题中接受的答案,你需要做这样的事情。
$str = "www.test.com/director-sales-120";
$arr=explode("-",$str);
$vacancies = $arr[2];
define( 'PHPFMG_SUBJECT' , "We have $vacancies vacancies" );
查看您提供的功能。除了设置一些局部变量之外,它确实没有做任何事情。因此,如果这个答案不起作用,我们可能需要从该函数中看到更多代码。
答案 1 :(得分:0)
您的解决方案尚未运行。我试图将$ vacancies复制到subject subject字段中,但邮件的主题是空的。
我有两个文件,一个是mailform,另一个是form.lib。
在mailform中我有这段代码:
<input type="hidden"style="font-weight:bold" formmethod="POST" name="field_5" id="field_5" value=" <php str="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$arr=explode("-",$str); $vacancynumber=end($arr); echo end($arr); ?>"
这使得该字段确实显示了发送邮件中的空缺号码。但是现在我必须在这个主题中提出这个数字......
.lib文件显示了这个(它显示了更多,但我认为这是相关的代码):
<?php define( 'PHPFMG_SUBJECT' , "" );?>
<?php
$msg = ob_get_contents() ;
ob_end_clean();
return trim($msg);}
$GLOBALS['form_mail'] = array();
$GLOBALS['form_mail']['field_0'] = array( "name" => "field_0", "text" => "Voornaam", "type" => "senderfirstname", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_1'] = array( "name" => "field_1", "text" => "Achternaam", "type" => "senderlastname", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_2'] = array( "name" => "field_2", "text" => "E-mail", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_3'] = array( "name" => "field_3", "text" => "(Mobiel) Telefoonnummer", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_4'] = array( "name" => "field_4", "text" => "Woonplaats", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_5'] = array( "name" => "field_5", "text" => "Vacaturenummer", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_7'] = array( "name" => "field_7", "text" => "Upload je CV", "type" => "attachment", "instruction" => "", "required" => "Required" ) ;
$GLOBALS['form_mail']['field_8'] = array( "name" => "field_8", "text" => "Akkoord privacy", "type" => "checkbox", "instruction" => "", "required" => "" ) ;
$GLOBALS['form_mail']['field_9'] = array( "name" => "field_9", "text" => "Hoe heb je ons gevonden?", "type" => "checkbox", "instruction" => "", "required" => "Required" ) ;?>
function sendFormMail( $form_mail, $sFileName = "" )
{
$to = filterEmail(PHPFMG_TO) ;
$cc = filterEmail(PHPFMG_CC) ;
$bcc = filterEmail(PHPFMG_BCC) ;
// simply chop email address to avoid my website being abused
if( false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') ){
$cc = substr($cc, 0, 50);
$bcc = substr($bcc,0, 50);
};
$subject = PHPFMG_SUBJECT ;
$from = $to ;
$fromName = "";
$titleOfSender = '';
$firstName = "";
$lastName = "";
$strip = get_magic_quotes_gpc() ;
$content = '' ;
$style = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ;
$tr = array() ; // html table
$csvValues = array();
$cols = array();
$replace = array();
$RecordID = phpfmg_getRecordID();
$isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) );
foreach( $form_mail as $field ){
$field_type = strtolower($field[ "type" ]);
if( 'sectionbreak' == $field_type ){
continue;
};
$value = trim( $_POST[ $field[ "name" ] ] );
$value = $strip ? stripslashes($value) : $value ;
if( 'attachment' == $field_type ){
$value = $isWritable ? phpfmg_file2value( $RecordID, $_FILES[ $field[ "name" ] ] ) : $_FILES[ $field[ "name" ] ]['name'];
//$value = $_FILES[ $field[ "name" ] ]['name'];
};
$content .= $field[ "text" ] . " \t : " . $value .PHPFMG_LNCR;
$tr[] = "<tr> <td valign=top style='{$style};width:33%;border-right:1px solid #cccccc;'>" . $field[ "text" ] . " </td> <td valign=top style='{$style};'>" . nl2br($value) . " </td></tr>" ;
$csvValues[] = csvfield( $value );
$cols[] = csvfield( $field[ "text" ] );
$replace["%".$field[ "name" ]."%"] = $value;
switch( $field_type ){
case "sender's email" :
$from = filterEmail($value) ;
break;
case "sender's name" :
$fromName = filterEmail($value) ;
break;
case "titleofsender" :
$titleOfSender = $value ;
break;
case "senderfirstname" :
$firstName = filterEmail($value) ;
break;
case "senderlastname" :
$lastName = filterEmail($value) ;
break;
default :
// nothing
};