SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    el salvador
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy php variables in a MIME html mail

    HI everyone. let me explain to you my problem.

    I want to send and html mail with php. But i want this html mail to have some cuztomizable information.

    i don't know how to do this, or if it is posible.

    Let's asume that we have a form with 5 variables.(senderName, senderAdress,receiverName,receiverAdress,comment) wich ar send it via POST to a php file, who do the sending job.

    this php file takes those variables and use them in the mail function, everything works, it sents the mail to the receiverAdress,
    "To: $receiverName <$receiverAdress>\n"
    from the receiver name:
    "From: $senderName\n"
    and send the html file.

    but the problem is the i want to include some of those variables (receiverName,senderName,comment) into the html , but it ignore php code inside the html code.

    Also i want to know if i can send a picture(how's stored in a database) inside that html code,


    i don't know if i make myself clear.

    please help me.

    thanks for your time

  2. #2
    Setting up a connection... mgyth's Avatar
    Join Date
    Nov 2004
    Location
    Mosjøen - Norway
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I can't really help you...
    Adding image attachement can be done using headers, not sure how to do it.

    I to want to add variables in my $message ' ';
    So I'm just gonna subscribe to this thread...

    Sorry I couldn't help you in any way...

  3. #3
    SitePoint Mentor bronze trophy

    Join Date
    Oct 2004
    Location
    UK
    Posts
    2,659
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    How about:

    PHP Code:
    $to $_POST['receiverAddress'];
    $subject "Hello";
    $from "From:  ".$_POST['senderAddress']."\n";
    $body "Hi, ".$_POST['receiverName'].".\n\n";
    $body .= "Do you like my email?\n\n";
    $body .= "To unsubscribe <a href = 'unsub.php?email=".$_POST['receiverAddress']."'>click here.</a>";

    mail($to,$subject,$body,$from); 

  4. #4
    Setting up a connection... mgyth's Avatar
    Join Date
    Nov 2004
    Location
    Mosjøen - Norway
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Actually I was working on this right now, and i found that using:
    PHP Code:
    $message "
    <html>
    <head>
    <style type=\"text/css\">
    .plain \{
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size:10px;
      color:#666666;
    }
    </style>
    </head>
    <body>
    <span class=\"plain\">Any html code u might need + 
    $variables u might need...</span>
    </body>
    </html>

    Works fine....
    just enclose the html in " ", and escape all the " and the { in the html...

    I guess any php functions u want done must be done 'before' u put the variables in the $message""...

    I'm a neewbie so there might be an easier way to do this...

  5. #5
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use heredoc syntax when you set the message variable.

    Its explained here.

    http://www.phpbuilder.com/manual/lan...syntax.heredoc


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •