2011-09-06 5 views
-2

다음 스크립트를 AppGini 응용 프로그램의 후크로 사용하여 양식이 제출 될 때 메시지를 보냅니다. 제대로 작동하지만 일반 텍스트로되어 있습니다. html 형식을 삽입하는 데 여러 번 시도했지만 각각의 시도가 실패로 끝났습니다. PHP 후크에서 html로 문자 메시지를 사용합니다.

@mail(
    "{$data['client_suiting_location']}@nonprofit.org", 
    "Client Referral", 
    "Referral_contact:  {$data['referral_contact']} 
    Referral Partner:  $referral_partner 
    Referral Contact Email:  $referral_email 
    Date:       {$data['creation_date']} 
    Client name:     {$data['client_name']} 
    Client telephone:    {$data['client_telephone']} 
    Client alternate telephone:  {$data['client_alternate_telephone']} 
    Client suiting location:  {$data['client_suiting_location']} 
    Client Interview Dates:   {$data['client_interview_details']} 
    Client Spanish only:  {$data['client_spanish']} 
    Client Career Center:  {$data['client_career_center']} 
    Client Coaching Requests: {$data['client_career_requests']} 
    Client Interview Details: {$data['client_interview']} 
    Client clothes sizes:  {$data['client_clothes_sizes']} 
    Client requests:  {$data['client_requests']} 
    Client preferences:  {$data['client_preferences']} 
    Client email:   {$data['client_email']} 
    client address1:  {$data['client_address1']} 
    Client address2:  {$data['client_address2']} 
    Client city:   {$data['client_city']} 
    Client state:   {$data['client_state']} 
    Client zip:   {$data['client_zip']} 
    Client age:   {$data['client_age']} 
    Client height:   {$data['client_height']} 
    Client weight:   {$data['client_weight']} 
    Client_ethnicity:  {$data['client_ethnicity']} 
    Client_educ_level:  {$data['client_educ_level']} 
    Client_dependents:  {$data['client_dependents']} 
    Client_marital_status:  {$data['client_marital_status']} 
    Client_public_assistance: {$data['client_public_assistance']} 
    Client_employment_status: {$data['client_employment_status']}", 
    "$referral_email" 
    ); 

내가 보내고 싶은 메시지의 스타일

가 여기에 있습니다 : http://www.grovesonline.com/mail/

+1

귀하의 질문에 더 나은 포맷, 실제로 당신은, 당신은 단지 메일 본문에 텍스트의 톤을 채우고있는 HTML 전자 메일을 생성하지 않는 –

+1

질문을하시기 바랍니다. HTML + 평문 메일 생성을 쉽게하려면 [Swiftmailer] (http://swiftmailer.org) 및/또는 [PHPMailer] (http://phpmailer.worxware.com)를 확인하십시오. –

+0

엄청난 양의 전자 메일을 사용하면'$ data' 키 배열과 영어 정의를 만든 다음'$ data'의 값으로 영어 정의를 출력하는 함수에 매핑하는 것이 더 쉽습니다. –

답변

3

정말이에 대한 사전 구축 된 메일 링 클래스를 사용해야합니다, 일부는 위의 제안되었다.

그러나 mail()만을 사용하려면 아래 코드를 사용하여 multipart/alternative 형식의 메시지를 보내야합니다. 위의 템플릿이 약간 씩 복잡하고 HTML이 합리화와 함께 할 수 있다는 점을 유의하십시오.

$referral_email 변수에 올바른 헤더가 포함되어 있다고 생각합니다. 나는 그것이 아마 당신이 mail() : "From: $referral_email"에 보낼 때와 같이 지정에 추가되어야한다고 생각합니다. 그러나 질문에서 100 % 확신 할 수 없습니다.

<?php 

    $bodytext = <<<EOD 
    Referral_contact:  {$data['referral_contact']} 
    Referral Partner:  $referral_partner 
    Referral Contact Email:  $referral_email 
    Date:       {$data['creation_date']} 
    Client name:     {$data['client_name']} 
    Client telephone:    {$data['client_telephone']} 
    Client alternate telephone:  {$data['client_alternate_telephone']} 
    Client suiting location:  {$data['client_suiting_location']} 
    Client Interview Dates:   {$data['client_interview_details']} 
    Client Spanish only:  {$data['client_spanish']} 
    Client Career Center:  {$data['client_career_center']} 
    Client Coaching Requests: {$data['client_career_requests']} 
    Client Interview Details: {$data['client_interview']} 
    Client clothes sizes:  {$data['client_clothes_sizes']} 
    Client requests:  {$data['client_requests']} 
    Client preferences:  {$data['client_preferences']} 
    Client email:   {$data['client_email']} 
    client address1:  {$data['client_address1']} 
    Client address2:  {$data['client_address2']} 
    Client city:   {$data['client_city']} 
    Client state:   {$data['client_state']} 
    Client zip:   {$data['client_zip']} 
    Client age:   {$data['client_age']} 
    Client height:   {$data['client_height']} 
    Client weight:   {$data['client_weight']} 
    Client_ethnicity:  {$data['client_ethnicity']} 
    Client_educ_level:  {$data['client_educ_level']} 
    Client_dependents:  {$data['client_dependents']} 
    Client_marital_status:  {$data['client_marital_status']} 
    Client_public_assistance: {$data['client_public_assistance']} 
    Client_employment_status: {$data['client_employment_status']} 
EOD; 

    $bodyhtml = <<<EOD 
<html> 

<head> 
<meta http-equiv="Content-Language" content="en-us"> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 
<title>Email Template</title> 
</head> 

<body> 

<table border="0" width="1024"> 
    <tr> 
     <td colspan="4" height="100"> 
     <p align="center"> 
     &nbsp;</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Date</font></span></td> 
     <td width="310" align="left">{$data['creation_date']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Referral Partner</font></span></td> 
     <td width="310" align="left">$referral_partner</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Referral Contact</font></span></td> 
     <td width="310" align="left">{$data['referral_contact']}</td> 
     <td width="216"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Referral Contact Email</font></span></td> 
     <td width="271" align="left">$referral_email</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     &nbsp;</td> 
     <td width="310" align="left">&nbsp;</td> 
     <td width="216" align="left">&nbsp;</td> 
     <td width="271" align="left">&nbsp;</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Client Name</font></span></td> 
     <td width="310" align="left">{$data['client_name']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Telephone</font></span></td> 
     <td width="310" align="left">{$data['client_telephone']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Spanish</font></span></td> 
     <td width="310" align="left">{$data['client_spanish']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Alternate telephone</font></span></td> 
     <td width="310" align="left">{$data['client_alternate_telephone']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Suiting Location</font></span></td> 
     <td width="310" align="left">{$data['client_suiting_location']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Career Center Visit</font></span></td> 
     <td width="310" align="left">{$data['client_career_center']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Interview Details</font></span></td> 
     <td width="310" align="left">{$data['client_interview_details']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Coaching Requests</font></span></td> 
     <td width="310" align="left">{$data['client_career_requests']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Clothes Sizes</font></span></td> 
     <td width="310" align="left">{$data['client_clothes_sizes']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Preferences</font></span></td> 
     <td width="310" align="left">{$data['client_preferences']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Client Email</font></span></td> 
     <td width="310" align="left">{$data['client_email']}</td> 
     <td width="216" align="left">&nbsp;</td> 
     <td width="271" align="left">&nbsp;</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Client Address</font></span></td> 
     <td width="310" align="left">{$data['client_address1']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Address 2</font></span></td> 
     <td width="310" align="left">{$data['client_address2']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">City</font></span></td> 
     <td width="310" align="left">{$data['client_city']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">State</font></span></td> 
     <td width="310" align="left">{$data['client_state']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     &nbsp;</td> 
     <td width="310" align="left">&nbsp;</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Zip</font></span></td> 
     <td width="310" align="left">{$data['client_zip']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Age</font></span></td> 
     <td width="310" align="left">{$data['client_age']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Height</font></span></td> 
     <td width="310" align="left">{$data['client_height']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Weight</font></span></td> 
     <td width="310" align="left">{$data['client_weight']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Ethnicity</font></span></td> 
     <td width="310" align="left">{$data['client_ethnicity']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Education Level</font></span></td> 
     <td width="310" align="left">{$data['client_educ_level']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Dependents</font></span></td> 
     <td width="310" align="left">{$data['client_dependents']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Marital Status</font></span></td> 
     <td width="310" align="left">{$data['client_marital_status']}</td> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Public Assistance</font></span></td> 
     <td width="310" align="left">{$data['client_public_assistance']}</td> 
    </tr> 
    <tr> 
     <td width="197"> 
     <span style="orphans: 2; text-align: -webkit-auto; widows: 2; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-weight: 700"> 
     <font size="2" face="Verdana">Employed</font></span></td> 
     <td width="310" align="left">{$data['client_employment_status']}</td> 
     <td width="216" align="left">&nbsp;</td> 
     <td width="271" align="left">&nbsp;</td> 
    </tr> 
    </table> 

</body> 

</html> 
EOD; 

    $boundary = '------'.md5(time()).'------'; 
    $body = "This is a multipart message in MIME format\r\n$boundary\r\nContent-Type: text/plain\r\n\r\n$bodytext\r\n$boundary\r\nContent-Type: text/html\r\nContent-Transfer-Encoding: base64\r\n\r\n".base64_encode($bodyhtml)."\r\n$boundary--"; 

    @mail("{$data['client_suiting_location']}@nonprofit.org","Client Referral",$body,"Content-Type: multipart/alternative; boundary=\"$boundary\"\r\n$referral_email"); 

?> 
+0

가능한 해결책을 가져 주셔서 감사합니다. 배를 사용하여 생성 된 응용 프로그램 외부에서 작동하는 함수가 있습니다. –