Jump to content

Recommended Posts

Here's the mail content, what is sent off to the user.

[code]$mailContent="Name:".$fname." ".$lname." "."sent the following preapplication materials \n\n"
           ."Name: ".$fname." ".$lname.": I am ".$gender."\n"
           ."Address: ".$address."\n"
           ."Telephone: ".$telephone."\n"
           ."E-mail: ".$email."\n"
           ."Country of Citizenship: ".$country."\n"
           ."Degree sought ".$degreesought."\n\n"

                       ."College of University \n"
                          ."Name and Location \n"
                       .$c1."\n"
                       ."Dates attended \n"
                       .$c1dts."\n"
                       ."Major \n"
                       .$clmj."\n"
                       ."Degree \n"
                       .$cldgre."\n"
                       ."Deg. Date \n"
                       .$clddt."\n"
                       ."GPA \n"
                       .$clgpa."\n\n"

                   ."College of University 2 \n"
                       ."Name and Location \n"
                       .$c2."\n"
                       ."Dates attended \n"
                       .$c2dts."\n"
                       ."Major \n"
                       .$c2mj."\n"
                       ."Degree \n"
                       .$c2dgre."\n"
                       ."Deg. Date \n"
                       .$c2ddt."\n"
                       ."GPA \n"
                       .$c2gpa."\n\n"

                       ."College of University 3 \n"
                       ."Name and Location \n"
                       .$c3."\n"
                       ."Dates attended \n"
                       .$c3dts."\n"
                       ."Major \n"
                       .$c3mj."\n"
                       ."Degree \n"
                       .$c3dgre."\n"
                       ."Deg. Date \n"
                       .$c3ddt."\n"
                       ."GPA \n"
                       .$c3gpa."\n\n"

                       ."
<html><table width='100%' border='0'>
  <tr>
    <td>Course Type </td>
    <td>Sem. 1 </td>
    <td>Sem. 2 </td>
  </tr>
  <tr>
    <td>General Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem2."</td>
  </tr>
  <tr>
    <td>Physical Chemistry </td>
    <td>".$pchem1."</td>
    <td>".$pchem2."</td>
  </tr>
  <tr>
    <td>Analytical Chemistry </td>
    <td>".$achem1."</td>
    <td>".$achem2."</td>
  </tr>
  <tr>
    <td>Biochemistry</td>
    <td>".$bchem1."</td>
    <td>".$bchem1."</td>
  </tr>
  <tr>
    <td>Organic Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem1."</td>
  </tr>
  <tr>
    <td>Physics</td>
    <td>".$phy1."</td>
    <td>".$phy2."</td>
  </tr>
  <tr>
    <td>Calculus</td>
    <td>".$calc1."</td>
    <td>".$calc2."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscia1."</td>
    <td rowspan='2'>".$oscia2."</td>
  </tr>
  <tr>
    <td>".$oscia."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscib1."</td>
    <td rowspan='2'>".$oscib2."</td>
  </tr>
  <tr>
    <td>".oscib."</td>
  </tr>
</table>
</body>
</html>
"."\n"; [/code]
Link to comment
https://forums.phpfreaks.com/topic/3943-e-mailing-html/#findComment-13690
Share on other sites

Hey willpower, great code but the problem is that only part of $mailContent needs to be formatted in html. I suppose I could rewrite the whole $mailContent variable to be in html, but I really don't want to do that unless I have to. What I tried, was put all the content that needs to be html formatted in a variable called $html , then I just conctated that to the $mailContent variable. All the information is sent when e-mailed, but the content that's not html is not formatted right. Hope this makes sense. The relevant code is below.

[code]
$html=<<<HTML_OUTPUT
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>Untitled Document</title>
</head>
<body>
<table width='100%' border='0'>
  <tr>
    <td>General Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem2."</td>
  </tr>
  <tr>
    <td>Physical Chemistry </td>
    <td>".$pchem1."</td>
    <td>".$pchem1."</td>
  </tr>
  <tr>
    <td>Analytical Chemistry</td>
    <td>".$achem1."</td>
    <td>".$achem1."</td>
  </tr>
  <tr>
    <td>Biochemistry</td>
    <td>".$bchem1."</td>
    <td>".$bchem1."</td>
  </tr>
  <tr>
    <td>Organic Chemistry</td>
    <td>".$ochem1."</td>
    <td>".$ochem1."</td>
  </tr>
  <tr>
    <td>Physics</td>
    <td>".$phy1."</td>
    <td>".$phy2."</td>
  </tr>
  <tr>
    <td>Calculus</td>
    <td>".$calc1."</td>
    <td>".$calc2."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan="2">".$oscia1."</td>
    <td rowspan="2">".$oscia2."</td>
  </tr>
  <tr>
    <td>".$oscia."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscib1."</td>
    <td rowspan='2'>".$oscib2."</td>
  </tr>
  <tr>
    <td>".$oscib."</td>
  </tr>
</table>
</body>
</html>
HTML_OUTPUT;

$mailContent="Name:".$fname." ".$lname." "."sent the following preapplication materials \n\n"
           ."Name: ".$fname." ".$lname.": I am ".$gender."\n"
           ."Address: ".$address."\n"
           ."Telephone: ".$telephone."\n"
           ."E-mail: ".$email."\n"
           ."Country of Citizenship: ".$country."\n"
           ."Degree sought: ".$dgresot."\n\n"

                       ."College of University \n"
                          ."Name and Location: \n"
                       .$c1."\n"
                       ."Dates attended: \n"
                       .$c1dts."\n"
                       ."Major: \n"
                       .$c1mj."\n"
                       ."Degree: \n"
                       .$c1dgre."\n"
                       ."Deg. Date: \n"
                       .$c1ddt."\n"
                       ."GPA: \n"
                       .$c1gpa."\n\n"

                   ."College of University 2 \n"
                       ."Name and Location: \n"
                       .$c2."\n"
                       ."Dates attended: \n"
                       .$c2dts."\n"
                       ."Major: \n"
                       .$c2mj."\n"
                       ."Degree: \n"
                       .$c2dgre."\n"
                       ."Deg. Date: \n"
                       .$c2ddt."\n"
                       ."GPA: \n"
                       .$c2gpa."\n\n"

                       ."College of University 3 \n"
                       ."Name and Location: \n"
                       .$c3."\n"
                       ."Dates attended \n"
                       .$c3dts."\n"
                       ."Major: \n"
                       .$c3mj."\n"
                       ."Degree: \n"
                       .$c3dgre."\n"
                       ."Deg. Date: \n"
                       .$c3ddt."\n"
                       ."GPA: \n"
                       .$c3gpa."\n".
                       $html.

"GRE Scores \n".
"Verbal        ".$grev." ".$grevper."\n".
"Quant.        ".$grq." ".$greqper."\n".
"Analy.        ".$grea." ".$greaper."\n".
"Total        ".$total."\n".

"Subject GRE: Subject: ".$gresub."  Score: ".$gresubscore."   ".$gresubper."\n".
"TOEFL Score: ".$toefl."\n".
"Areas of Research interest: ".$interest."\n".
"Publications: ".$pubs."\n".
"Additional Information: ".$addinfo."\n".
"Server protocol: ".$remotehost."\n".
"Remote IP address: ".$ip."\n";
//End of $mailcontent

$headers = "From: xxx  \r\n";
$headers .="Reply-to: xxx  \r\n";
$headers .="MIME-Version: 1.0\r\n";
$boundary = uniqid ("something");
$headers .="Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .="This is a MIME encoded message. \r\n\r\n";
$headers .="--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" ."Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$textversion"));
$headers .="--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$mailContent"));


$email2="asiegrist@gmail.com";
$subject="Preapplication (Forms submission)";


if (!$lname) {
       echo "<b>Thank you</b> <br> You have not provided your last/family
name. All requested information must be submitted
       or we will not be able to properly process your preapplication";
       }
else {
    mail($email2, $subject, $mailContent, $headers);
    echo "Thank you for submitting a preapplication. Our graduate committee will review the materials and advise you of
their decision.";
    }
[/code]
Link to comment
https://forums.phpfreaks.com/topic/3943-e-mailing-html/#findComment-13823
Share on other sites

I can't get this to work. I'm using:

[code]<?php
$bar = <<<HTML_OUTPUT
<img src="http://www.site.com/images/picture.gif">
HTML_OUTPUT;
?>
<a href="javascript:addmsgtxt('Greetings,\n\n<?php $bar ?>')">Greetings</a><br>
[/code]

I'm using javascript to insert the image into the <textarea> field, but its not including the code when it sends. What am I doing wrong? If I just type in the code into the textarea field and send it, it only displays the code in the email and not the picture I'm trying to insert.

I've tried sending html using my custom mailing list for the longest time, and everything I try fails.
Link to comment
https://forums.phpfreaks.com/topic/3943-e-mailing-html/#findComment-13829
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.