Link to home
Start Free TrialLog in
Avatar of zoobie
zoobieFlag for United States of America

asked on

Passing variables into mailer

Hello -

This will be an easy 250 points for someone familiar with passing variables. I'm using PHP version 4.0.6. and I almost had it but grew tired of trial and error. You could probably get it on close to the first try. The author's gone AWOL.

I need to have 2 selected variables (gifs) and comments from myform.php page passed into the example.html page which is then sent via the mailer.

Like I said, this will probably be easy. I have changed the files into text files for easy viewing and they are complete with comments. The html file example.html is just a regular page and can be viewed in the files listed below. The mailer just opens files, embeds them, and sends whatever's in the example.html. I have commented out some un-needed coding in the send.php but feel free to reinclude it if needed.

The files you will need to view are:
http://geocities.com/zoobie007/mimemailer/send.txt  (myform.php's action=send.php)
http://geocities.com/zoobie007/mimemailer/class.html.mime.mail.txt

Other files you probably won't need to view:
http://geocities.com/zoobie007/mimemailer/class.smtp.txt
http://geocities.com/zoobie007/mimemailer/mimePart.txt
http://geocities.com/zoobie007/mimemailer/example.html

One last thing...The debugging should be turned off. When I comment it out, it throws an error.

Enjoy!

Sincerely,

Z

Here is:
myform.php

<html><head></head><body>
<form name=myform method=post action=send.php
<input type="text" name="receiver" size="20">

<select name="pic">
<option>Pictures</option>
<option value="alfred">Alfred</option>
<option value="smiley">Smiley</option>
</select>

<select name="pic2">
<option>Pictures</option>
<option value="goofy">Goofy</option>
<option value="chips">Chips</option>
</select>

<textarea name="comments" cols="44" rows="11" wrap="VIRTUAL"></textarea>

<input type="submit" name="Submit" value="Send">
<input type="reset" name="Clear" Value="Clear">
</form></body></html>







Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

If you cut'n'pasted your code, try ...

<form name=myform method=post action=send.php>

Note the > at the end of the line.
Can you say what is NOT working?
Or do you want to know how to access HTML form variables in PHP?

In older versions of PHP, you would use ...

$HTTP_method_VARS["variable_name"]

where method can be ...

POST, GET, COOKIES, SERVER

So,

to access the variable "receiver" which has been POSTed, in older PHP's, you would use

$HTTP_POST_VARS["receiver"]



In newer PHPs you would use

$_method["variable"]

e.g.

$_POST["receiver"]


You can then treat these as your PHP variables, or, if you want, move them to local storage.

Richard.
Avatar of zoobie

ASKER

Quote: "I need to have 2 selected variables (gifs) and comments from myform.php page passed into the example.html page which is then sent via the mailer."
 
This is on a virtual host, btw.

I'm finished doing trial and error. I will just keep posting 'till someone cashes in...I have all year.

Both the send.php and the example.php needs fixing so the above can be accomplished.
Just to be sure ...

You want to upload 2 GIF images to the server and then have then emailed or simple names of 2 GIF images?

If they are names, where are they coming from?

Or have you hard-coded them?

Or you want to select 2 images you already have on the server and have them emailed?

Or are you just emailing the names?

But, I think I sort of understand what you want.

In your send.php you have 2 lines ...

        $text = $mail->get_file('example.txt');
        $html = $mail->get_file('example.html');

These relate to the files stored locally.


Try this ...


<?php
/***************************************
** Filename.......: example.1.php
** Project........: HTML Mime Mail class
** Last Modified..: 01 October 2001
***************************************/

/*

      Having trouble? Read this article on HTML email: http://www.arsdigita.com/asj/mime/

*/#
        error_reporting(E_ALL);
        include('class.html.mime.mail.inc');

/***************************************
** Example of usage. This example shows
** how to use the class with html,
** embedded images, and an attachment,
** using the usual methods.
***************************************/

      /***************************************
        ** This is optional, it will default to \n
      ** If you're having problems, try changing
      ** this to either \n (unix) or \r (Mac)
        ***************************************/

            define('CRLF', "\r\n", TRUE);

        /***************************************
        ** Create the mail object. Optional headers
        ** argument. Do not put From: here, this
        ** will be added when $mail->send
        ** Does not have to have trailing \r\n
        ** but if adding multiple headers, must
        ** be seperated by whatever you're using
      ** as line ending (usually either \r\n or \n)
        ***************************************/

        $mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));

      /***************************************
        ** Read the image background.gif into
      ** $background
        ***************************************/

        $background = $mail->get_file('background.gif');

        /***************************************
        ** Read the file test.zip into $attachment.
        ***************************************/

        //$attachment = $mail->get_file('example.zip');

        /***************************************
        ** If sending an html email, then these
        ** two variables specify the text and
        ** html versions of the mail. Don't
        ** have to be named as these are. Just
        ** make sure the names tie in to the
        ** $mail->add_html() call further down.
        ***************************************/

/* _RAQ_ Create the text and HTML messages. */
      $sText = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$_POST["receiver"]}.

The pictures you want are {$_POST["pic"]} and {$_POST["pic2"]}.

Your comments are :

{$_POST["comments"]}

Thank you.
<<<END_TEXT;

      $sHtml = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$_POST["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$_POST["pic"]}</b> and <b>{$_POST["pic2"]}</b>.</div>
<div>Your comments are :<br><br><b>{$_POST["comments"]}</b></div>
<div>Thank you.</div>
<<<END_TEXT;
      
/* _RAQ_ Save the text and HTML messages into temporary files.

NOTE : You will need to check your servers tmp location or have adequate permissions to write to your own directory!!!
*/
      $tmpText = tempnam ("/tmp", "_mail_text_");
      $tmpHtml = tempnam ("/tmp", "_mail_html_");
      $fp = fopen($tmpText, "w");
      fwrite($fp, $sText);
      fclose($fp);
      $fp = fopen($tmpHtml, "w");
      fwrite($fp, $sHtml);
      fclose($fp);

/* Use the temporary filenames. */
        $text = $mail->get_file($tmpText);
        $html = $mail->get_file($tmpHtml);

        /***************************************
        ** Add the text, html and embedded images.
        **  The name of the image should match exactly
        ** (case-sensitive) to the name in the html.
        ***************************************/

        $mail->add_html($html, $text);
        $mail->add_html_image($background, 'background.gif', 'image/gif');

        /***************************************
        ** This is used to add an attachment to
        ** the email.
        ***************************************/

        //$mail->add_attachment($attachment, 'example.zip', 'application/zip');

        /***************************************
        ** Builds the message.
        ***************************************/

        if(!$mail->build_message())
            die('Failed to build email');

        /***************************************
        ** Send the email using smtp method.
      ** This is the preferred method of sending.
        ***************************************/

        include('class.smtp.inc');

            $params = array(
                                    'host' => '10.1.1.2',            // Mail server address
                                    'port' => 25,                        // Mail server port
                                    'helo' => 'example.com',      // Use your domain here.
                                    'auth' => FALSE,                  // Whether to use authentication or not.
                                    'user' => '',                        // Authentication username
                                    'pass' => ''                        // Authentication password
                                 );

        $smtp =& smtp::connect($params);

            $send_params = array(
                        'from'            => 'joe@example.com',                  // The return path
                        'recipients'      => 'richard@[10.1.1.2]',            // Can be more than one address in this array.
                        'headers'      => array(
                              'From: "Joe" <joe@example.com>',
                              'To: "Richard Heyes" <richard@[10.1.1.2]>',      // A To: header is necessary, but does
                              'Subject: Test email'                        // not have to match the recipients list.
                              )
                        );
        $mail->smtp_send($smtp, $send_params);

/* _RAQ_ Delete the temporary files. */
      unlink($tmpText);
      unlink($tmpHtml);

        /***************************************
        ** Debug stuff. Entirely unnecessary.
        ***************************************/

        echo '<PRE>'.htmlentities($mail->get_rfc822('Richard', 'richard@[10.1.1.2]', 'Joe', 'joe@example.com', 'Example email using HTML Mime Mail class')).'</PRE>';
?>


Note. The code I've added has _RAQ_ in the comments to help you find the changes.

Is this the sort of thing you are wanting?

Regards,

Richard Quadling.
Oops.

On the lines that START with <<<

Remove the <<<

Should be ...

$sText = <<<END_TEXT

...

END_TEXT;



NOT

<<<END_TEXT;

The same for the END_HTML too.

Sorry.

Richard.
Avatar of zoobie

ASKER

Ok Richard...This is a completely different way than my last attempt...

Anyway, it's giving me:
Parse error: parse error in /www/php50.com/html/zoobie/send.php on line 172
As far as I know, there IS no domain "html" or line 172 for that matter.

The mailer grabs a file...in this case, gifs, and embeds it into the email. This is why I'm thinking the example.html should be modified to accept the variables.

Something like:

example.html
<html><head></head><body>
<img src="$pic.gif"></img>
<img src="$pic2.gif"></img>
$comments
</body></html>

like the directions say to do...except they say to use the actual file name e.g. <img src="smiley.gif"> which of course, I can't do because it's a variable from myform.php page containing several choices.

I'm also using $HTTP_POST_VARS["pic"] as it's version 4.0.6
Did you remove the extra <<<'s?

Can you also change the extension on the HTML file as all I get is a "Well done you sent it" message.
Avatar of zoobie

ASKER

And something like perhaps:

 $pic = $mail->get_file('$HTTP_POST_VARS["pic"]');
 $pic2 = $mail->get_file('$HTTP_POST_VARS["pic2"]');

 $mail->add_html_image($pic, '$pic.gif', 'image/gif');
 $mail->add_html_image($pic2, '$pic2.gif', 'image/gif');

I have no idea...obviously.

Thanks


Avatar of zoobie

ASKER

Yes...I removed the extra <<<'s

This is what I have so far. I've commented some things out for testing. Maybe it's that permissions you mentioned...:

<?php
/***************************************
** Filename.......: example.1.php
** Project........: HTML Mime Mail class
** Last Modified..: 01 October 2001
***************************************/

/*

     Having trouble? Read this article on HTML email: http://www.arsdigita.com/asj/mime/

*/#
       error_reporting(E_ALL);
       include('xxx.php');

/***************************************
** Example of usage. This example shows
** how to use the class with html,
** embedded images, and an attachment,
** using the usual methods.
***************************************/

     /***************************************
       ** This is optional, it will default to \n
     ** If you're having problems, try changing
     ** this to either \n (unix) or \r (Mac)
       ***************************************/

          define('CRLF', "\r\n", TRUE);

       /***************************************
       ** Create the mail object. Optional headers
       ** argument. Do not put From: here, this
       ** will be added when $mail->send
       ** Does not have to have trailing \r\n
       ** but if adding multiple headers, must
       ** be seperated by whatever you're using
     ** as line ending (usually either \r\n or \n)
       ***************************************/

       $mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));

     /***************************************
       ** Read the image background.gif into
     ** $background
       ***************************************/

       //$background = $mail->get_file('background.gif');

       /***************************************
       ** Read the file test.zip into $attachment.
       ***************************************/

       //$attachment = $mail->get_file('example.zip');

       /***************************************
       ** If sending an html email, then these
       ** two variables specify the text and
       ** html versions of the mail. Don't
       ** have to be named as these are. Just
       ** make sure the names tie in to the
       ** $mail->add_html() call further down.
       ***************************************/

/* _RAQ_ Create the text and HTML messages. */
     $sText = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$HTTP_POST_VARS["receiver"]}.

The pictures you want are {$HTTP_POST_VARS["pic"]}.
//and {$HTTP_POST_VARS["pic2"]}.

Your comments are :

{$HTTP_POST_VARS["comments"]}

Thank you.
END_TEXT;

     $sHtml = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$HTTP_POST_VARS["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$HTTP_POST_VARS["pic"]}.</div>
//</b> and <b>{$HTTP_POST_VARS["pic2"]}</b>
<div>Your comments are :<br><br><b>{$HTTP_POST_VARS["comments"]}</b></div>
<div>Thank you.</div>
END_TEXT;
     
/* _RAQ_ Save the text and HTML messages into temporary files.

NOTE : You will need to check your servers tmp location or have adequate permissions to write to your own directory!!!
*/
     $tmpText = tempnam ("/tmp", "_mail_text_");
     $tmpHtml = tempnam ("/tmp", "_mail_html_");
     $fp = fopen($tmpText, "w");
     fwrite($fp, $sText);
     fclose($fp);
     $fp = fopen($tmpHtml, "w");
     fwrite($fp, $sHtml);
     fclose($fp);

/* Use the temporary filenames. */
       $text = $mail->get_file($tmpText);
       $html = $mail->get_file($tmpHtml);

       /***************************************
       ** Add the text, html and embedded images.
       **  The name of the image should match exactly
       ** (case-sensitive) to the name in the html.
       ***************************************/

       $mail->add_html($html, $text);
      // $mail->add_html_image($background, 'background.gif', 'image/gif');

       /***************************************
       ** This is used to add an attachment to
       ** the email.
       ***************************************/

       //$mail->add_attachment($attachment, 'example.zip', 'application/zip');

       /***************************************
       ** Builds the message.
       ***************************************/

       if(!$mail->build_message())
           die('Failed to build email');

       /***************************************
       ** Send the email using smtp method.
     ** This is the preferred method of sending.
       ***************************************/

       include('yyy.php');

          $params = array(
                              'host' => 'smtp.softhome.net',          // Mail server address
                              'port' => 25,                    // Mail server port
                              'helo' => 'mydomain.com',     // Use your domain here.
                              'auth' => TRUE,               // Whether to use authentication or not.
                              'user' => 'me@softhome.net',                    // Authentication username
                              'pass' => '111zzz'                    // Authentication password
                            );

       $smtp =& smtp::connect($params);

          $send_params = array(
                    'from'          => 'joe@example.com',               // The return path
                    'recipients'     => 'zzzoobie@wmconnect.com',          // Can be more than one address in this array.
                    'headers'     => array(
                         'From: "Joe" <joe@example.com>',
                         'To: "Richard Heyes" <richard@[10.1.1.2]>',     // A To: header is necessary, but does
                         'Subject: Test email'                    // not have to match the recipients list.
                         )
                    );
       $mail->smtp_send($smtp, $send_params);

/* _RAQ_ Delete the temporary files. */
     unlink($tmpText);
     unlink($tmpHtml);

       /***************************************
       ** Debug stuff. Entirely unnecessary.
       ***************************************/

       echo '<PRE>'.htmlentities($mail->get_rfc822('Richard', 'richard@[10.1.1.2]', 'Joe', 'joe@example.com', 'Example email using HTML Mime Mail class')).'</PRE>';
?>
The second END_TEXT;

should be

END_HTML;

Sorry. My bad.
Avatar of zoobie

ASKER

Yes...I removed the extra <<<'s

This is what I have so far. I've commented some things out for testing. Maybe it's that permissions you mentioned...:

<?php
/***************************************
** Filename.......: example.1.php
** Project........: HTML Mime Mail class
** Last Modified..: 01 October 2001
***************************************/

/*

     Having trouble? Read this article on HTML email: http://www.arsdigita.com/asj/mime/

*/#
       error_reporting(E_ALL);
       include('xxx.php');

/***************************************
** Example of usage. This example shows
** how to use the class with html,
** embedded images, and an attachment,
** using the usual methods.
***************************************/

     /***************************************
       ** This is optional, it will default to \n
     ** If you're having problems, try changing
     ** this to either \n (unix) or \r (Mac)
       ***************************************/

          define('CRLF', "\r\n", TRUE);

       /***************************************
       ** Create the mail object. Optional headers
       ** argument. Do not put From: here, this
       ** will be added when $mail->send
       ** Does not have to have trailing \r\n
       ** but if adding multiple headers, must
       ** be seperated by whatever you're using
     ** as line ending (usually either \r\n or \n)
       ***************************************/

       $mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));

     /***************************************
       ** Read the image background.gif into
     ** $background
       ***************************************/

       //$background = $mail->get_file('background.gif');

       /***************************************
       ** Read the file test.zip into $attachment.
       ***************************************/

       //$attachment = $mail->get_file('example.zip');

       /***************************************
       ** If sending an html email, then these
       ** two variables specify the text and
       ** html versions of the mail. Don't
       ** have to be named as these are. Just
       ** make sure the names tie in to the
       ** $mail->add_html() call further down.
       ***************************************/

/* _RAQ_ Create the text and HTML messages. */
     $sText = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$HTTP_POST_VARS["receiver"]}.

The pictures you want are {$HTTP_POST_VARS["pic"]}.
//and {$HTTP_POST_VARS["pic2"]}.

Your comments are :

{$HTTP_POST_VARS["comments"]}

Thank you.
END_TEXT;

     $sHtml = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$HTTP_POST_VARS["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$HTTP_POST_VARS["pic"]}.</div>
//</b> and <b>{$HTTP_POST_VARS["pic2"]}</b>
<div>Your comments are :<br><br><b>{$HTTP_POST_VARS["comments"]}</b></div>
<div>Thank you.</div>
END_TEXT;
     
/* _RAQ_ Save the text and HTML messages into temporary files.

NOTE : You will need to check your servers tmp location or have adequate permissions to write to your own directory!!!
*/
     $tmpText = tempnam ("/tmp", "_mail_text_");
     $tmpHtml = tempnam ("/tmp", "_mail_html_");
     $fp = fopen($tmpText, "w");
     fwrite($fp, $sText);
     fclose($fp);
     $fp = fopen($tmpHtml, "w");
     fwrite($fp, $sHtml);
     fclose($fp);

/* Use the temporary filenames. */
       $text = $mail->get_file($tmpText);
       $html = $mail->get_file($tmpHtml);

       /***************************************
       ** Add the text, html and embedded images.
       **  The name of the image should match exactly
       ** (case-sensitive) to the name in the html.
       ***************************************/

       $mail->add_html($html, $text);
      // $mail->add_html_image($background, 'background.gif', 'image/gif');

       /***************************************
       ** This is used to add an attachment to
       ** the email.
       ***************************************/

       //$mail->add_attachment($attachment, 'example.zip', 'application/zip');

       /***************************************
       ** Builds the message.
       ***************************************/

       if(!$mail->build_message())
           die('Failed to build email');

       /***************************************
       ** Send the email using smtp method.
     ** This is the preferred method of sending.
       ***************************************/

       include('yyy.php');

          $params = array(
                              'host' => 'smtp.softhome.net',          // Mail server address
                              'port' => 25,                    // Mail server port
                              'helo' => 'mydomain.com',     // Use your domain here.
                              'auth' => TRUE,               // Whether to use authentication or not.
                              'user' => 'me@softhome.net',                    // Authentication username
                              'pass' => '111zzz'                    // Authentication password
                            );

       $smtp =& smtp::connect($params);

          $send_params = array(
                    'from'          => 'joe@example.com',               // The return path
                    'recipients'     => 'zzzoobie@wmconnect.com',          // Can be more than one address in this array.
                    'headers'     => array(
                         'From: "Joe" <joe@example.com>',
                         'To: "Richard Heyes" <richard@[10.1.1.2]>',     // A To: header is necessary, but does
                         'Subject: Test email'                    // not have to match the recipients list.
                         )
                    );
       $mail->smtp_send($smtp, $send_params);

/* _RAQ_ Delete the temporary files. */
     unlink($tmpText);
     unlink($tmpHtml);

       /***************************************
       ** Debug stuff. Entirely unnecessary.
       ***************************************/

       echo '<PRE>'.htmlentities($mail->get_rfc822('Richard', 'richard@[10.1.1.2]', 'Joe', 'joe@example.com', 'Example email using HTML Mime Mail class')).'</PRE>';
?>
Avatar of zoobie

ASKER

Warning: Undefined index: pic2 in /www/php50.com/html/zoobie/send.php on line 74

Warning: Undefined index: pic2 in /www/php50.com/html/zoobie/send.php on line 88

Warning: open_basedir restriction in effect. File is in wrong directory in /www/php50.com/html/zoobie/send.php on line 99

Warning: fopen("/tmp/_mail_text_nvbKuf","w") - Operation not permitted in /www/php50.com/html/zoobie/send.php on line 99

Warning: Supplied argument is not a valid File-Handle resource in /www/php50.com/html/zoobie/send.php on line 100

Warning: Supplied argument is not a valid File-Handle resource in /www/php50.com/html/zoobie/send.php on line 101

Warning: open_basedir restriction in effect. File is in wrong directory in /www/php50.com/html/zoobie/send.php on line 102

Warning: fopen("/tmp/_mail_html_v5sx1X","w") - Operation not permitted in /www/php50.com/html/zoobie/send.php on line 102

Warning: Supplied argument is not a valid File-Handle resource in /www/php50.com/html/zoobie/send.php on line 103

Warning: Supplied argument is not a valid File-Handle resource in /www/php50.com/html/zoobie/send.php on line 104

Warning: open_basedir restriction in effect. File is in wrong directory in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)

Warning: fopen("/tmp/_mail_text_nvbKuf","rb") - Operation not permitted in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)

Warning: open_basedir restriction in effect. File is in wrong directory in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)

Warning: fopen("/tmp/_mail_html_v5sx1X","rb") - Operation not permitted in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)
Failed to build email
Avatar of zoobie

ASKER

Can't we just pass the variables into the example.html or doesn't it work that way?
Avatar of zoobie

ASKER

Can't we just pass the variables into the example.html or doesn't it work that way?
Your server will only allow you open files from a specific directory (I think) - Warning: open_basedir restriction in effect - speak to your sysop for this setting, or check out phpinfo();

-------info.php--------
<?php
phpinfo();
?>
-------info.php--------

This will show you the settings you have.

You will need to change "/tmp" to a directory you DO have read/write access to. Ask your sysop for that. Try using "./" instead of "/tmp".

As you can't write the files, you can't open them either, so this is a lof of those errors.

To add inline images, try ...


<images src='cid:{$HTTP_POST_VARS["pic"]}'>

in the HTML part and

use the add attachement method to add $HTTP_POST_VARS["pic"] to the list.

Make sure you add the correct extension to this too as the list seems to only contain the NAME and not the extension (gif/jpg/etc).

Richard.
Avatar of zoobie

ASKER

Close...

Ok...I changed /temp to ./ and it's writing. I've also added
$attachment = $mail->get_file('$HTTP_POST_VARS["pic".gif]'); but this throwing the error below.

I'm getting this echo:


Warning: Unable to access $HTTP_POST_VARS["pic".gif] in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)


Warning: fopen("$HTTP_POST_VARS["pic".gif]","rb") - No such file or directory in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)


Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/send.php on line 162

Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/send.php on line 163

Date: Fri, 19 Jul 02 19:29:38
From: "Joe" <joe@example.com>
To: "Richard" <zzzoobie@wmconnect.com>
Subject: Example email using HTML Mime Mail class
MIME-Version: 1.0
X-Mailer: Html Mime Mail Class
Content-Type: multipart/alternative;
     boundary="=_e6d01c8aa5df5fcb5f2b1805de9a43b8"

--=_e6d01c8aa5df5fcb5f2b1805de9a43b8
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello.

This is a plain text email.

You want to send this email to zzzoobie@wmconnect.com.

The pictures you want are smiley.gif and smiley.gif .


Your comments are :

aol test 5

Thank you.
--=_e6d01c8aa5df5fcb5f2b1805de9a43b8
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>zzzoobie@wmconnect.com</b>.</div>
<div>The pictures you want are <img src=3D'cid:smiley.gif'> and <img src=3D=
'cid:smiley.gif'>.</div>
<div>Your comments are :<br><br><b>aol test 5</b></div>
<div>Thank you.</div>
--=_e6d01c8aa5df5fcb5f2b1805de9a43b8--

Avatar of zoobie

ASKER

Close...

Ok...I changed /temp to ./ and it's writing. I've also added
$attachment = $mail->get_file('$HTTP_POST_VARS["pic".gif]'); but this throwing the error below.

I'm getting this echo:


Warning: Unable to access $HTTP_POST_VARS["pic".gif] in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)


Warning: fopen("$HTTP_POST_VARS["pic".gif]","rb") - No such file or directory in /www/php50.com/html/zoobie/xxx.php on line 104 (this is class.mime.mail.php)


Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/send.php on line 162

Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/send.php on line 163

Date: Fri, 19 Jul 02 19:29:38
From: "Joe" <joe@example.com>
To: "Richard" <zzzoobie@wmconnect.com>
Subject: Example email using HTML Mime Mail class
MIME-Version: 1.0
X-Mailer: Html Mime Mail Class
Content-Type: multipart/alternative;
     boundary="=_e6d01c8aa5df5fcb5f2b1805de9a43b8"

--=_e6d01c8aa5df5fcb5f2b1805de9a43b8
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello.

This is a plain text email.

You want to send this email to zzzoobie@wmconnect.com.

The pictures you want are smiley.gif and smiley.gif .


Your comments are :

aol test 5

Thank you.
--=_e6d01c8aa5df5fcb5f2b1805de9a43b8
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>zzzoobie@wmconnect.com</b>.</div>
<div>The pictures you want are <img src=3D'cid:smiley.gif'> and <img src=3D=
'cid:smiley.gif'>.</div>
<div>Your comments are :<br><br><b>aol test 5</b></div>
<div>Thank you.</div>
--=_e6d01c8aa5df5fcb5f2b1805de9a43b8--

Try

$HTTP_POST_VARS["pic1"] . ".gif"

The $HTTP_POST_VARS["pic1"]  gives you the name and then you add the extension to it.

So if pic1 contains fred ...


$HTTP_POST_VARS["pic1"] . ".gif"

>

"fred" . ".gif"

>

"fred.gif"


The unlink error is your system. I would suggest you talk you your sysop and ask them to give you a read/write directory and allow you to unlink files from that directory. If they do, then you will need to change the "\tmp" to the directory they give you.

Alternatively, if they have a scratch area which is cleaned out hourly, daily, etc, then that can be used. If so, then you can remove the unlink command as the system will clean files out anyway. Not a lot you can do about this until you've spoken to your sysop.

When you receive the email, do you get a placeholder for the images?

Richard.

Avatar of zoobie

ASKER

The error says it's expecting another "}" in this line:
The picture you want is {$HTTP_POST_VARS["pic1"] . ".gif"}
but I've tried putting it everywhere.

And no...the placeholders don't show up because the mail isn't being sent.

I also found another example:

  /***************************************
        ** Add the text, html and embedded images.
          ** Here we're using the third argument of
          ** add_html(), which is the path to the
          ** directory that holds the images. By
          ** adding this third argument, the class
          ** will try to find all the images in the
          ** html, and auto load them in. Not 100%
          ** accurate, and you MUST enclose your
          ** image references in quotes, so src="img.jpg"
          ** and NOT src=img.jpg. Also, where possible,
          ** duplicates will be avoided.
        ***************************************/

        $mail->add_html($html, $text, './');

The problem is, the above method is used via mail() rather than smtp which I'm using and includes another the smtp.mime.php file.

Could we use this?

Avatar of zoobie

ASKER

The error says it's expecting another "}" in this line:
The picture you want is {$HTTP_POST_VARS["pic1"] . ".gif"}
but I've tried putting it everywhere.

And no...the placeholders don't show up because the mail isn't being sent.

I also found another example:

  /***************************************
        ** Add the text, html and embedded images.
          ** Here we're using the third argument of
          ** add_html(), which is the path to the
          ** directory that holds the images. By
          ** adding this third argument, the class
          ** will try to find all the images in the
          ** html, and auto load them in. Not 100%
          ** accurate, and you MUST enclose your
          ** image references in quotes, so src="img.jpg"
          ** and NOT src=img.jpg. Also, where possible,
          ** duplicates will be avoided.
        ***************************************/

        $mail->add_html($html, $text, './');

The problem is, the above method is used via mail() rather than smtp which I'm using and includes another the smtp.mime.php file.

Could we use this?

Ah.

Ok.

The use of {} inside a heredoc (the <<< stuff) restricts what can actually be created.

You will need to produce 2 new variables OUTSIDE of that part of the code.

Just above the $sText creation add ...

$sPic1 = $HTTP_POST_VARS["pic1"] . ".gif";
$sPic2 = $HTTP_POST_VARS["pic2"] . ".gif";

And replace the

{$HTTP_POST_VARS["pic1"]}

in the heredoc with

$sPic1

Repeat for the second pic.

Richard.
Avatar of zoobie

ASKER

Warning: Unable to access $HTTP_POST_VARS["pic"] . ".gif" in /www/php50.com/html/zoobie/class.html.mime.mail.php on line 104

Warning: fopen("$HTTP_POST_VARS["pic"] . ".gif"","rb") - No such file or directory in /www/php50.com/html/zoobie/class.html.mime.mail.php on line 104

Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/zmail2.php on line 168

Warning: unlink() has been disabled for security reasons. in /www/php50.com/html/zoobie/zmail2.php on line 169

Date: Mon, 22 Jul 02 15:49:34
From: "Joe" <joe@example.com>
To: "Richard" <zzzoobie@wmconnect.com>
Subject: Example email using HTML Mime Mail class
MIME-Version: 1.0
X-Mailer: Html Mime Mail Class
Content-Type: multipart/alternative;
     boundary="=_1a446825fe93c6f18dd8d600218b1a42"

--=_1a446825fe93c6f18dd8d600218b1a42
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


Hello.

This is a plain text email.

You want to send this email to zzzoobie@wmconnect.com.

The pictures you want are smiley.gif and smiley.gif .


Your comments are :

aol test 87459487564785683847563

Thank you.
--=_1a446825fe93c6f18dd8d600218b1a42
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>zzzoobie@wmconnect.com</b>.</div>
<div>The pictures you want are <img src=3D'cid:smiley.gif'> and <img src=3D=
'cid:smiley.gif'>.</div>
<div>Your comments are :<br><br><b>aol test 87459487564785683847563</b></di=
v>
<div>Thank you.</div>
--=_1a446825fe93c6f18dd8d600218b1a42--

What have you done?

Can you show me your current code again.

The line ...

fopen("$HTTP_POST_VARS["pic"] . ".gif"","rb")

is totally wrong!!

This should be ...

fopen($HTTP_POST_VARS["pic"] . ".gif","rb")

The   .   command adds text strings together.

Inside " . " this is just a dot with 2 spaces. It won't do anything.

Can you try (repeated) ...

The use of {} inside a heredoc (the <<< stuff) restricts what can actually be created.

You will need to produce 2 new variables OUTSIDE of that part of the code.

Just above the $sText creation add ...

$sPic1 = $HTTP_POST_VARS["pic1"] . ".gif";
$sPic2 = $HTTP_POST_VARS["pic2"] . ".gif";

And replace the

{$HTTP_POST_VARS["pic1"]}

in the heredoc with

$sPic1

Repeat for the second pic.




Richard.

Avatar of zoobie

ASKER

It's putting in the extra double quotes on it's own by referencing the class.html.mime.mail.php

Not only that...but I can't be asking an already paranoid host for special permissons.

Sorry...but I just don't think this way is gonna work.

How about using the third arguement ('./') and put <img src=$HTTP_POST_VARS["pic1"] . ".gif"> or just <img src="cid:$pic.gif"> in the example.html page?

I kind of find it hard to believe there isn't some easier way than asking permissions, writing temp files, etc.

I appreciate your help.
The class you are using wants FILES not TEXT. If you can amend the class to accept the text then you don't need to write the files.

I assume that the class opens the file and reads lines from it. You could replace that with the created $sText and $sHTML variables.

That would require a bit more work.

You can try ...


<img src='{$HTTP_POST_VARS["pic1"]}.gif'>

I think the mixing of single and double quotes is getting a little out of hand <grin> (I have to use a colour editor which shows them up nicely).

If the name sent in pic1 is FOO, then above line SHOULD result in ...

<img src='foo.gif'>

which is totally valid.

Richard.
Avatar of zoobie

ASKER

Let's try just one image for now.

I used the very simple third arguement where it finds and inserts the file (a few posts back) in the example.html and it still spit out:

Warning: Unable to access {$HTTP_POST_VARS["pic"]}.gif in /www/php50.com/html/zoobie/class.html.mime.mail.php on line 106

Warning: fopen("{$HTTP_POST_VARS["pic"]}.gif","rb") - No such file or directory in /www/php50.com/html/zoobie/class.html.mime.mail.php  on line 106

...but it looks like it will work. That way, we don't need to ask permissions or write files.

The <img src='{$HTTP_POST_VARS["pic"]}.gif'> isn't receiving the passed file either.

Tell you what...Why don't you go to http://www.phpguru.org/mime.mail.html and d/l the script complete with examples and work on it. When you get it solved, I'll give you 400 points. I need to send the email via SMTP method (example 1 & 2).

Need a free test host? http://www.php50.com is using v4.0.6

What say?

Thanks




-----input.html-------------
<html>
<head>
<title>Test Email</title>
</head>
<body>
<form method="POST" action="mailtest.php">
What is your email address <input type="text" name="receiver"><br>
Choose your first picture <select name="pic1">
<option value="pic1.gif">Pic1 (gif)
<option value="pic2.gif">Pic2 (gif)
<option value="pic3.gif">Pic3 (gif)
<option value="pic4.gif">Pic4 (gif)
<option value="pic5.gif">Pic5 (gif)
</select><br>
Choose your second picture <select name="pic2">
<option value="pic1.jpg">Pic1 (jpeg)
<option value="pic2.jpg">Pic2 (jpeg)
<option value="pic3.jpg">Pic3 (jpeg)
<option value="pic4.jpg">Pic4 (jpeg)
<option value="pic5.jpg">Pic5 (jpeg)
</select><br>
<textarea rows="5" cols="60" name="comments"></textarea><br>
<input type="submit" name="Send Email" value="Send Email">
</form>
</body>
</html>



--------------mailtest.php----------------
<?php
error_reporting(E_ALL);
include('htmlMimeMail.php');

$mail = new htmlMimeMail();

$text = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$HTTP_POST_VARS["receiver"]}.

The pictures you want are {$HTTP_POST_VARS["pic1"]} and {$HTTP_POST_VARS["pic2"]}.

Your comments are :

{$HTTP_POST_VARS["comments"]}

Thank you.
END_TEXT;

$html = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$HTTP_POST_VARS["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$HTTP_POST_VARS["pic1"]}</b> and <b>{$HTTP_POST_VARS["pic2"]}</b>.</div>
<div>These images are <img src="cid:{$HTTP_POST_VARS["pic1"]}"> and <img src="cid:{$HTTP_POST_VARS["pic2"]}">.</div>
<div>Your comments are :<br><br><b>{$HTTP_POST_VARS["comments"]}</b></div>
<div>Thank you.</div>
END_HTML;


$mail->setHtml($html, $text);

$mail->setFrom('"Richard" <Richard@example.com>');
$mail->setSubject('Test mail');
$mail->setHeader('X-Mailer', 'HTML Mime mail class (http://www.phpguru.org)');
         
$result = $mail->send(array('postmaster@localhost'), 'smtp');

if (!$result)
     {
     print_r($mail->errors);
     }
else
     {
     echo 'Mail sent!';
     }
?>
Avatar of zoobie

ASKER

Ugh...just updated...just my luck.

I had to search thru 4 files just to find the username and password settings...Still haven't found how to set where it gets sent.

It's all in ascii....don't know if I'm actually going to be able to set this...
Avatar of zoobie

ASKER

Ugh...just updated...just my luck.

I had to search thru 4 files just to find the username and password settings...Still haven't found how to set where it gets sent.

It's all in ascii....don't know if I'm actually going to be able to set this...
Avatar of zoobie

ASKER

Wait...I see it.

$mail->setSMTPParams('smtp.softhome.net', 25, "php50.com', TRUE, 'me@softhome.net',  '12321');

$result = $mail->send(array('zzzoobie@wmconnect.com'), 'smtp');

Working...

Avatar of zoobie

ASKER

Warning: dirname() has been disabled for security reasons. in /www/php50.com/html/zoobie/htmlMimeMail.php on line 10

Warning: Unable to access /mimePart.php in /www/php50.com/html/zoobie/htmlMimeMail.php on line 10

Fatal error: Failed opening required '/mimePart.php' (include_path='.:/usr/share/php') in /www/php50.com/html/zoobie/htmlMimeMail.php on line 10

Line #10=require_once(dirname(__FILE__) . '/mimePart.php');
Unfortunately, it seems like your server is not set up to allow you to use all the functions of PHP.

This is probably VERY common on servers where the ISP is worried about potential abuse.

Also, PEAR does not seem to be pathed in properly. I suspect you will not be able to do much about that.

Sorry.

Show the script to your ISP and ask them to allow it to run. They can either say yes or no. If no, then you would be advised to change to a different ISP.

Richard.
Avatar of zoobie

ASKER

Well, I'll be...

He changed the code. I tried it at another host and it doesn't work there either.

Would it work with the previous version in the links given in my first post?

The SMTP worked fine with the earlier version...
I've not fully explored PEAR, so I can't answer that.

The pear code is standard, but if there are security issues, then these can only be resolved by talking to the ISP.

Richard.
Avatar of zoobie

ASKER

Well, I'll be...

He changed the code. I tried it at another host and it doesn't work there either.

Would it work with the previous version in the links given in my first post?

The SMTP worked fine with the earlier version...
Avatar of zoobie

ASKER

I have the older version...Want to take a crack at that? I could send it...I do know the earlier version sent everything fine and he didn't use the dirname()
What happens if you use my scripts with the older class?

What errors do you get then?
Avatar of zoobie

ASKER

With the old, I keep getting the Warning: Unable to access $HTTP_POST_VARS["pic"] . ".gif"

I've also bookmarked about 10 free php sites, too.
You need to use the 2 files I created. That is the old one.

Here they are again ...

-----input.html-------------
<html>
<head>
<title>Test Email</title>
</head>
<body>
<form method="POST" action="mailtest.php">
What is your email address <input type="text" name="receiver"><br>
Choose your first picture <select name="pic1">
<option value="pic1.gif">Pic1 (gif)
<option value="pic2.gif">Pic2 (gif)
<option value="pic3.gif">Pic3 (gif)
<option value="pic4.gif">Pic4 (gif)
<option value="pic5.gif">Pic5 (gif)
</select><br>
Choose your second picture <select name="pic2">
<option value="pic1.jpg">Pic1 (jpeg)
<option value="pic2.jpg">Pic2 (jpeg)
<option value="pic3.jpg">Pic3 (jpeg)
<option value="pic4.jpg">Pic4 (jpeg)
<option value="pic5.jpg">Pic5 (jpeg)
</select><br>
<textarea rows="5" cols="60" name="comments"></textarea><br>
<input type="submit" name="Send Email" value="Send Email">
</form>
</body>
</html>



--------------mailtest.php----------------
<?php
error_reporting(E_ALL);
include('htmlMimeMail.php');

$mail = new htmlMimeMail();

$text = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$HTTP_POST_VARS["receiver"]}.

The pictures you want are {$HTTP_POST_VARS["pic1"]} and {$HTTP_POST_VARS["pic2"]}.

Your comments are :

{$HTTP_POST_VARS["comments"]}

Thank you.
END_TEXT;

$html = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$HTTP_POST_VARS["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$HTTP_POST_VARS["pic1"]}</b> and <b>{$HTTP_POST_VARS["pic2"]}</b>.</div>
<div>These images are <img src="cid:{$HTTP_POST_VARS["pic1"]}"> and <img src="cid:{$HTTP_POST_VARS["pic2"]}">.</div>
<div>Your comments are :<br><br><b>{$HTTP_POST_VARS["comments"]}</b></div>
<div>Thank you.</div>
END_HTML;


$mail->setHtml($html, $text);

$mail->setFrom('"Richard" <Richard@example.com>');
$mail->setSubject('Test mail');
$mail->setHeader('X-Mailer', 'HTML Mime mail class (http://www.phpguru.org)');
         
$result = $mail->send(array('postmaster@localhost'), 'smtp');

if (!$result)
    {
    print_r($mail->errors);
    }
else
    {
    echo 'Mail sent!';
    }
?>

Use these and tell me what happens.
Avatar of zoobie

ASKER

Well, it looks like he changed most of the classes with the new update. I'll try your code with the mail->addhtml($html,$text); bit...

I noticed that this host is ultra consertive so I'll open a few new accounts today and try it there.
Avatar of zoobie

ASKER

Richard -

Hey...For the first time, I got it to work without any errors using your code and the earlier version.

I used:

<?php

     error_reporting(E_ALL);
       include('class.html.mime.mail.php');

       define('CRLF', "\r\n", TRUE);

   $mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));

$text = <<<END_TEXT
Hello.

This is a plain text email.

You want to send this email to {$HTTP_POST_VARS["receiver"]}.

The pictures you want are {$HTTP_POST_VARS["pic1"]} and {$HTTP_POST_VARS["pic2"]}.

Your comments are :

{$HTTP_POST_VARS["comments"]}

Thank you.
END_TEXT;

$html = <<<END_HTML
<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>{$HTTP_POST_VARS["receiver"]}</b>.</div>
<div>The pictures you want are <b>{$HTTP_POST_VARS["pic1"]}</b> and <b>{$HTTP_POST_VARS["pic2"]}</b>.</div>
<div>These images are <img src="cid:{$HTTP_POST_VARS["pic1"]}"> and <img src="cid:{$HTTP_POST_VARS["pic2"]}">.</div>
<div>Your comments are :<br><br><b>{$HTTP_POST_VARS["comments"]}</b></div>
<div>Thank you.</div>
END_HTML;

  $mail->add_html($html, $text);

      if(!$mail->build_message())
           die('Failed to build email');

  include('class.smtp.php');

          $params = array(
                              'host' => 'smtp.softhome.net',          // Mail server address
                              'port' => 25,                    // Mail server port
                              'helo' => 'mydomain.com',     // Use your domain here.
                              'auth' => TRUE,               // Whether to use authentication or not.
                              'user' => 'me@softhome.net',                    // Authentication username
                              'pass' => 'zzz1zzz'                    // Authentication password
                            );

       $smtp =& smtp::connect($params);

          $send_params = array(
                    'from'          => 'joe@example.com',               // The return path
                    'recipients'     => 'zzzoobie@wmconnect.com',          // Can be more than one address in this array.
                    'headers'     => array(
                         'From: "Joe" <joe@example.com>',
                         'To: "Richard Heyes" <richard@[10.1.1.2]>',     // A To: header is necessary, but does
                         'Subject: Test email'                    // not have to match the recipients list.
                         )
                    );
       $mail->smtp_send($smtp, $send_params);


       /***************************************
       ** Debug stuff. Entirely unnecessary.
       ***************************************/

       echo '<PRE>'.htmlentities($mail->get_rfc822('Richard', 'zzzoobie@wmconnect.com', 'Joe', 'joe@example.com', 'Example email using HTML Mime Mail class')).'</PRE>';

?>

...which yielded:

Date: Fri, 26 Jul 02 02:57:39
From: "Joe" <joe@example.com>
To: "Richard" <zzzoobie@wmconnect.com>
Subject: Example email using HTML Mime Mail class
MIME-Version: 1.0
X-Mailer: Html Mime Mail Class
Content-Type: multipart/alternative;
      boundary="=_985d26989b0481dcd5303c2b69699739"

--=_985d26989b0481dcd5303c2b69699739
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello.

This is a plain text email.

You want to send this email to you@doofus.com.

The pictures you want are alfred.gif and smiley.gif.

Your comments are :

ok...my test text

Thank you../
--=_985d26989b0481dcd5303c2b69699739
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>you@doofus.com</b>.</div>
<div>The pictures you want are <b>alfred.gif</b> and <b>smiley.gif</b>.</di=
v>
<div>These images are <img src=3D"cid:alfred.gif"> and <img src=3D"cid:smil=
ey.gif">.</div>
<div>Your comments are :<br><br><b>ok...my test text</b></div>
<div>Thank you.</div>
--=_985d26989b0481dcd5303c2b69699739--


It's echoing...but not really sending unles my email is down now.

What it's missing is the passing of the variable into these:

$background = $mail->get_file('background.gif');
$mail->add_html_image($background, 'background.gif', 'image/gif');

Maybe we could change the $background bit above...but if I remember correctly, it doesn't want to get that file.



Try replacing ...

 $mail->add_html($html, $text);

     if(!$mail->build_message())
          die('Failed to build email');

with ...


 $mail->add_html($html, $text);

$background = $mail->get_file('background.gif');
$mail->add_html_image($background, 'background.gif', 'image/gif');

     if(!$mail->build_message())
          die('Failed to build email');


And see what happens.

You will need to check your email too, so make sure you are putting proper email addresses in.

Richard.
Avatar of zoobie

ASKER

Umm...no, I don't need to send any background. That was an example.

$picture1=$mail->get_file('$HTTP_POST_VARS["pic1"]')
and
$mail->add_html_image($picture1,'$HTTP_POST_VARS["pic1"]', 'image/gif');
is what I need to have working properly...but I think it's throwing an error. Is the above right?
The get-file method gets the contents of a file.

The add_html_images requires 3 parameters.

The first one is the data to be used.
The second one is the name to be looked for in the HTML data.
The third one is the type.

You are putting the $HTTP.... in a single quote which means this is the name.

if ...

$pot = 'fred' then

"$pot" == "fred", but '$pot' == '$pot'

So, try ...

$mail->add_html_image($picture1,$HTTP_POST_VARS["pic1"], 'image/gif');

Richard.
Avatar of zoobie

ASKER

Heyyyyy! I think we're really close now! It grabbed the file! Right now, I'm just using pic1 and it's still not sending...but look at the echo below.

I added:

$picture1 = $mail->get_file($HTTP_POST_VARS["pic1"]);

$mail->add_html_image($picture1,$HTTP_POST_VARS["pic1"], 'image/gif');

and got this echo:

Date: Sat, 27 Jul 02 03:38:08
From: "Joe" <joe@example.com>
To: "Richard" <zzzoobie@wmconnect.com>
Subject: Example email using HTML Mime Mail class
MIME-Version: 1.0
X-Mailer: Html Mime Mail Class
Content-Type: multipart/alternative;
      boundary="=_2659e2a01437357d84019b2f024cec0b"

--=_2659e2a01437357d84019b2f024cec0b
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello.

This is a plain text email.

You want to send this email to zzzoobie@wmconnect.com.

The pictures you want are smiley.gif and alfred.gif.

Your comments are :

We are very very close now...

Thank you../
--=_2659e2a01437357d84019b2f024cec0b
Content-Type: multipart/related;
      boundary="=_8c3fd912b73b231320d9f0bc679846eb"

--=_8c3fd912b73b231320d9f0bc679846eb
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<div>Hello.</div>
<div>This is a plain text email.</div>
<div>You want to send this email to <b>zzzoobie@wmconnect.com</b>.</div>
<div>The pictures you want are <b>cid:366c5db557cc69bd9f64b1080ca8b1b5</b> =
and <b>alfred.gif</b>.</div>
<div>These images are <img src=3D"cid:cid:366c5db557cc69bd9f64b1080ca8b1b5"=
> and <img src=3D"cid:alfred.gif">.</div>
<div>Your comments are :<br><br><b>We are very very close now...</b></div>
<div>Thank you.</div>
--=_8c3fd912b73b231320d9f0bc679846eb
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="smiley.gif"
Content-ID: <366c5db557cc69bd9f64b1080ca8b1b5>

R0lGODlhQABaAPEAAPz+/Pz+BAQCBAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJZAAAACwAAAAA
QABaAAEC/4SPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCnmCovFYrBkD
zKaTaXwtn1RqNFWsardJk2AL5pKy4bJVEPqa19aPmg1vojnvuH2eqdvv+b1fjqH3B4dHIThIWHGI
mDixyLhW+PAIGSlBWVkmyYAJNRX5Cbap0InU6XmkOalpWtqq2uBqyjobNnogi0Sra+uQm2r72ssJ
CrxLBkvKZmzG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2VtYmxlZCB3aXRoIEdJRiBDb25zdHJ1Y3Rpb24gU2V0Og0KDQpBbGNoZW15IE1pbmR3b3JrcyBJ
bmMuDQpCb3ggNTAwDQpCZWV0b24sIE9ODQpMMEcgMUEwDQpDQU5BREEuDQoNCmh0dHA6Ly93d3cu
bWluZHdvcmtzaG9wLmNvbQ0KDQpUaGlzIGNvbW1lbnQgd2lsbCBub3QgYXBwZWFyIGluIGZpbGVz
IGNyZWF0ZWQgd2l0aCBhIHJlZ2lzdGVyZWQgdmVyc2lvbi4AOw0K
--=_8c3fd912b73b231320d9f0bc679846eb--
--=_2659e2a01437357d84019b2f024cec0b--

Looks like 2 cid's in there...I think they're supposed to within <img> tags...

Close...Want to finish it?
Avatar of GEM100
GEM100

You just just use
Content-type: text/html
with mail function and send <img src=http://yourserver.com/dir/filename.gif> tag...
Well done.

Now add in the second pic ...

$picture2 = $mail->get_file($HTTP_POST_VARS["pic2"]);

$mail->add_html_image($picture1,$HTTP_POST_VARS["pic2"], 'image/jpg');

This will add in the second picture.

Can you check that all the server you are using for sendmail is valid. If not, you will need to use the smtp connector instead.



Gem100 - Nope! That does not do inline images. That would simply generate a page requiring the mailreader to download the images.

Avatar of zoobie

ASKER

Success!

I got it on the first try and someone showed me how to pass variables via the string_replace method, too.

It easy when you are familiar with the script.

Now for just a couple more questions.

This works:

'recipients' => "$receiver",

but right underneath it, this doesn't:
                   
'To: "You" <$receiver>',

The <> tags are throwing the $receiver off and quotes don't work either.

Fix?

Also, how many points do you want for your help?

Thanks Richard

Best,

Z
                                                                 
You are mixing single and double quotes again.

Using quotes means treat everything inside them as plain text.

e.g.

echo "$name";

will show the contents of the variable $name.

echo '$name';

will show the $name on the screen, not the contents of $name, but the actually letters $, n, a, m and e.

Try ...

"To: \"You\" <$receiver>";

or

'To: "You" <' . $receiver . '>';


As for how many points, I will leave that up to you.

Richard.

Avatar of zoobie

ASKER

Yep...'To: "You" <'.$receiver.'>',

I was wondering about the include(blah.blah.blah.php);
Some hosts have the include disabled. Is there a way around that?

Ok...now the points...How do I award them if you've just commented? Don't you have to answer before awarded?

How many points would be fair?
If they have disbaled include, you will need to cut and paste the code. Watch out for the included file also including include/require!


You should be able to accept as answer any of my comments.


If you think more points should be awarded, you can amend the number of points before accepting any of my comments as an answer or you can create a new question called "Points for RQuadling" and I will place a comment in there which you then accept as an answer.

Regards,

Richard.
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zoobie

ASKER

Well, seeing as you answered my q's with professionalism, patience, and humour even though I'm new at this stuff, I think you deserve 400 points. Thanks again.

Best,

Z
Thank you.

I hope this all works for you OK. And good luck!
Avatar of zoobie

ASKER

Know anything about sessions? I'm using php v4.2.2 now and although your code above works fine in it, I can't seem to get the sessions to work now. They worked before...
check if session support is enabled. Actually, make a small php script with

<?php
echo phpinfo();
?>

and see what you have there on "session"
Avatar of zoobie

ASKER

I checked and it says: Session Support enabled

All those versions of php...Are they really necessary??? Jeez...
check the chapter on sessions then on PHP.net

Yes, they are necessary, 4.2.2 was a security patch of 4.2.1 for instance. You don't want to live with security hole, right?