获取url的一部分以使邮件成为主题


Fetch part of url to make subject of mail

我刚刚收到了上一个问题的好答案:链接

除了这个答案,我还有一个新的挑战。

form.lib.php文件支持我的mailform,其中定义了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系统正在使用它来注册响应。

我怎样才能做到这一点?

如果我没有看错你当前的问题。使用你上一个问题的公认答案,你需要做这样的事情。

$str = "www.test.com/director-sales-120";
$arr=explode("-",$str);
$vacancies = $arr[2];
define( 'PHPFMG_SUBJECT' , "We have $vacancies vacancies" );

查看您提供的功能。它实际上什么都不做,只是设置一些局部变量。因此,如果这个答案不起作用,我们可能需要从该函数中看到更多的代码。

您的解决方案尚未运行。我试图将$空位复制到主题定义字段中,但邮件的主题是空的。

我有两个文件,一个是mailform,另一个是form.lib.

在邮件表单中,我有这样的代码:

 <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" ] . "&nbsp;</td> <td valign=top style='{$style};'>" . nl2br($value) . "&nbsp;</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                  
    };