Ask a Question related to Dreamweaver AppDev, Design and Development.
-
dlcmpls #1
PHP sending email problem
Hi all. I am attempting to use php to send an email that contains SESSION
variables provided by user forms. In the body of the email, I want to use
conditional code. So, for example, if Address2 was provided, show it in the
body of the email. If Address2 was not provided, don't show it in the email.
So here's the simplified version of my final form handler code (all session
variables have already been set and are working properly): ---------------
<?php //start the session session_start(); $date = date(' l F j, Y ');
$email1 = 'formrecipient@somewhere.com'; $headers = 'MIME-Version: 1.0\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1\r\n'; $headers .=
'From: $email\r\n'; $message1 = ' if ($_SESSION[address2]) { echo
\'$_SESSION[address2]<br>\' ; }'; mail('$email1', 'Web Site Sign-Up',
$message1, $headers); ?> <!--END PHP CODE--> <!--BEGIN ACTUAL PAGE CODE-->
<html> <body> <h2>Thank you for your message.</h2> <p>We will contact you
soon.</p> </body> </html> --------------- So I am having trouble with the
$message1 variable which becomes the body of the recipients email. I want
conditional code within the $message1 variable, but I'm stumped as to how to do
it! I'm assuming it has something to do with the double quotes, but that's as
far as I've made it! Please any help! Thanks, dlc
dlcmpls Guest
-
Problem saving and sending .pdf files via email
Hello, I am trying to remotely support a Mac user (OS X.2.2) with the use of forms created in Acrobat 5. She has Acrobat 6 standard installed. ... -
Sending an email from within ASP
I have a form which will be processed by being sent to an ASP page. I would like the ASP page to take the data from the Request.QueryString (which I... -
Sending email, problem with onLoad question
Everyone, I have a form that was created in Flash MX2004 Professional. The form is located on a layer called form and startes on frame 10. The... -
problem in sending email
Dear All, I have made a .asp file in order to send email to my email@email.com: <% Set mail = Server.CreateObject ("CDONTS.NewMail") ... -
Problem with sending email from asp.net page using smtp
hai i am requesting your technical support. please help me. i have been working with this for five days. the problem is relating with the... -
David Powers #2
Re: PHP sending email problem
dlcmpls wrote:
Since you're building your message as $message1, create it like this:> In the body of the email, I want to use
> conditional code. So, for example, if Address2 was provided, show it in the
> body of the email. If Address2 was not provided, don't show it in the email.
$message1 = $_SESSION['address1']."\n";
if (isset($_SESSION['address2'])) {
$message1 .= $_SESSION['address2']."\n";
}
and so on.
Your mistake was to use echo. You don't want to display the message in a
browser, but add it to the value of $message1.
--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
[url]http://computerbookshelf.com[/url]
David Powers Guest
-
dlcmpls #3
Re: PHP sending email problem
Ah, I see. So basically we just build a string of text as we go correct? Makes sense to me.
Thanks for the feedback you've helped me a lot!
dlc
dlcmpls Guest
-
dlcmpls #4
Re: PHP sending email problem
One other question David: I'd like to use a label in the email as well,
something like Address 1 = [Address1 variable] Email = [email variable] so
that what the email recipient sees is well formatted and understandable.
Suggestions?
dlcmpls Guest
-
David Powers #5
Re: PHP sending email problem
dlcmpls wrote:
Again, it's just a question of building a string:> One other question David: I'd like to use a label in the email as well,
> something like Address 1 = [Address1 variable] Email = [email variable] so
> that what the email recipient sees is well formatted and understandable.
> Suggestions?
$message1 = 'Address 1 = '.$_SESSION['Address1']."\n";
if (isset($_SESSION['Address2'])) {
$message1 .= 'Address 2 = '.$_SESSION['Address2']."\n";
}
$message1 .= 'Comments = '.$_SESSION['Comments']."\n";
You just build everything into one long string. It can be as long as you
like, mail() will still send it.
--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
http://computerbookshelf.com
David Powers Guest
-
dlcmpls #6
Re: PHP sending email problem
Got it. Thanks David. Your help is very much appreciated!
dlc
dlcmpls Guest



Reply With Quote

