Sending form content to E-mail Edit/Delete Message Reply w/Quote
I have form, which has SUBMIT button and would like to
send content of the form to E-mail address. What is procedure (script) to send this content per specific E-mail (MySQL and PHP).
I hope you can help
abectech
09-16-2005, 08:14 AM
www.php.net
Look up mail()
toplisek
09-16-2005, 10:28 AM
I have checked and posted code as following:
$address = '...;
$subject= '...';
$body="you got a message"
$mailsend = mail($address, $subject, $body);
echo $mailsend;
I'm new to this function. What should I put into code that it will send E-mail?
I hope you can help me
bokeh
09-16-2005, 12:04 PM
What you are trying to print is a boolean. Try this instead:
$address = 'recipient@domain.com';
$subject = 'subject text';
$body = 'body text'
$result = (mail($address, $subject, $body)) ? 'succeeded' : 'failed';
echo 'Sending mail to '.$address.' '.$result.'.';
758
09-16-2005, 01:21 PM
also, make sure to check to php.ini to make sure it is configured to send mail
toplisek
09-17-2005, 02:23 AM
thanks, now I understand. you are very helpful
toplisek
09-17-2005, 07:46 AM
I have also question how to determin:
"From: <someone@domain.com>"
if you have
$address = ''...'';
$subject= "...'';
$body= "...''
$result = (mail($address, $subject, $body)) ? 'succeeded' : 'failed';
and code:
--Myweb_multipart_boundary____________
Content-Type: text/plain;
and also:
--Myweb_multipart_boundary____________
Content-Type: text/html;
how does this code work and what is correct script ?
bokeh
09-20-2005, 07:12 AM
Well if an email is to contain html, plain and attached parts those parts must be separated with a boundary string and the whole email must comply with the relevant rfc. Below I have posted a function which prints out finished emails in their various forms so you can look at the differences. By the way this function makes ready to read emails and is not for use in conjunction with mail();
<?php
// Build mime or plain content
// $email = fill in the recipient
$email = 'you@your-email.com';
// $email_from = fill in the the sender
$email_from = 'me@my-email.com';
// Fill in the subject
$subject = 'Subject';
// Fill in email body text. Can include html tags.
$email_body = 'Body text';
// Attachments
// Any attachment should look like the following and include
// the file name and the path. Add as many as you like.
// $attachments[] = 'c:/path/to/file/filename.ext';
// $attachments[] = 'c:/path/to/another/file/another-filename.ext';
// HTML mail
// Set to TRUE for HTML email with plain text alterative or FALSE for plain text email
$html = FALSE;
Dear bokeh,
thanks. what do you mean
By the way this function makes ready to read emails and is not for use in conjunction with mail();
How to use this script? Is this to insert in my code? I'm new to this. Sorry.
bokeh
09-21-2005, 02:47 AM
That function produces output as it would appear in a .eml file.
bokeh
09-21-2005, 04:33 AM
Ok! The function above was just to show what a completed mail should look like. The following function will build and send mime mail with or without attachments. Just use it as a replacement for mail();
<?php
// function to send mime or plain email, with or without attachments
// $recipient = fill in the recipient
$recipient = 'you@your-email.com';
// $headers = fill in the the sender
$headers = 'From: me@my-email.com';
// Fill in the subject
$subject = 'Subject';
// Fill in email body text. Can include html tags.
$message = 'Body text';
// Attachments
// Any attachment should look like the following and include
// the file name and the path. Add as many as you like.
// $attachments[] = 'c:/path/to/file/filename.ext';
// HTML mail
// Set to TRUE to send HTML tags in the email body or FALSE for plain text email
$html = false;
this is great. It works.
I have just question how to define that HTML will work?
I have <a href=1_help.php>Help Department</a> and it does not work but I have defined $html = true; (there is also $html = NULL )
there is NULL and why is there this position?
I hope you can help
bokeh
09-22-2005, 09:36 AM
Don't change this:function send_mime_mail($recipient, $subject, $message, $headers = NULL, $html = NULL, $attachments = NULL)
{ it is correct. Just paste the function to the bottom of your script or put it in an external file and call it but don't make any changes to it.
If you want to include html <tags> do it like this:
// set variables
$message = 'Here is a <a href="href://www.dogs.com">link</a>!';
$subject = 'Interesting link';
$recipient = 'recipient@domain.com';
// Now send it
send_mime_mail($recipient, $subject, $message, NULL, TRUE);
I haven't tested that but if you can't make it work tell me and I will run a test .
toplisek
09-22-2005, 10:01 AM
I have body and HTML does not work, I have put $html = true;This is the only change. It recognised variables but HTM link not. Can you maybe test?
$message = "$namesen requested we send you this e-mail including this personal note:<BR><BR>
Hello $fnamerec $lnamerec,<BR><BR>
$bodysen<BR><BR>
$namesen<BR><BR>
***********************************************************
<BR><BR>
$namesen asked us to send you this information.<BR>
Please visit our <a href=help.php>Help Department</a> for questions.<BR><BR>
I tried this:$message = $namesen.' requested we send you this e-mail including this personal note:<BR><BR>'."\n".
'Hello '.$fnamerec.$lnamerec.',<BR><BR>'."\n".
$bodysen.'<BR><BR>'."\n".
$namesen.'<BR><BR>'."\n".
"\n".
'***********************************************************'."\n".
'<BR><BR>'."\n".
$namesen.' asked us to send you this information.<BR>'."\n".
'Please visit our <a href="http://bokehman.com/captcha_verification">Help Department</a> for questions.<BR><BR>'."\n".
"\n".
'***********************************************************'."\n";
send_mime_mail($recipient, $subject, $message, NULL, TRUE);
Note: The <a> tag should contain a full and properly quoted URL. Also the $message string should be properly quoted. If you are too lazy to quote the string use heredoc syntax.
Anyway the above tests positive and the link is highlighted in the email. When the link is selected it operates as expected.
toplisek
09-23-2005, 03:34 AM
this works,
problem is that when is sent to e.g. yahoo it works link,
but when I receive in Netscape on my local it does not show link.
I receive normally HTML messages.
bokeh
09-23-2005, 03:40 AM
Ok. So what is happening is this. The link is present in the html version but not in the plain text version and your Netscape is looking at the plain text version. I am working on this at the moment so will re-post the function shortly with changes later.
It is the same result. In Netscape I receive normally HTML messages. In your case there is no HTML link
bokeh
09-24-2005, 04:24 AM
What do you mean in my case. Did you add the code I posted. If not do so! When you receive the email in your mail client (e.g. outlook express) save it to the desktop with a .eml extention. Now open that file with a text editor and paste the contents to this forum. Once I see the output I will be able to tell if it is the email that has a problem or some other software you are using. When I tested this it worked fine. Obviously an HTML link can't work in plain text but the URL and link text were both present when I tested.
Post the email. I want the source, not the content.
toplisek
12-15-2005, 05:57 AM
Dear Bokeh,
please help me what to change that there wil be shown chartacters in Subject and in body like and č :rolleyes:
What do you mean with code:
Subject: =?UTF-8?B?YWJjxIxkZWY=?=
I have changed to unicode but it does not work.
Your code which I have was :) :
<?PHP
// function to send mime or plain email, with or without attachments
// $recipient = fill in the recipient
$contactLink1 = '<a href="...contactus.php">contact us</a>';
$contactLink2 = '<a href="...help.php">Help Department</a>';
$recipient = "$emailrec";
// $headers = fill in the the sender
$headers = "From: $emailsen" . "\r\n" .
"Reply-To: $emailsen";
// Fill in the subject
$subject = "$namesen wants you to see you";
// Fill in email body text. Can include html tags.
$message = $namesen.' requested we send you this e-mail including this personal note:<BR><BR>'."\n".
'Hello '.$fnamerec.' '.$lnamerec.',<BR><BR>'."\n".
$bodysen.'<BR><BR>'."\n".
$namesen.'<BR><BR>'."\n".
"\n".
'***********************************************************'."\n".
'<BR><BR>'."\n".
$namesen.' asked us to send you this information.<BR>'."\n".
'If you are interested in any products or services,<BR>
do not hesitate to ' .$contactLink1. '.<BR>'."\n".
'<br />Please visit our ' .$contactLink2. ' for questions.<BR><BR>'."\n".
"\n".
'With our warmest regards,<BR><BR>'."\n".
'Our web site team<BR>'."\n".
'***********************************************************'."\n";
// Attachments
// Any attachment should look like the following and include
// the file name and the path. Add as many as you like.
// $attachments[] = 'c:/path/to/file/filename.ext';
// HTML mail
// Set to TRUE to send HTML tags in the email body or FALSE for plain text email
$html = true;
Did you actually try running that code I posted as the subject? If not do so and you will see how it works.$subject = '=?UTF-8?B?YWJjxIxkZWY=?=';Here's the code to do that or similar:$subject = 'Espaņol';
$charset = 'ISO-8859-1';
$subject_encoded = '=?'.$charset.'?B?' . base64_encode($subject) . '?=';
print $subject_encoded;
toplisek
12-15-2005, 09:01 AM
$subject = '=?UTF-8?B?YWJjxIxkZWY=?=';
If I have variable and text:
$subject = "$namesen wants you to see you";
How to put into yout code?
I'm new to this, please suggest.
bokeh
12-15-2005, 09:20 AM
$subject = '=?UTF-8?B?YWJjxIxkZWY=?=';
If I have variable and text:
$subject = "$namesen wants you to see you";
How to put into yout code?
I'm new to this, please suggest.Are you serious? Have you read my post above? That was just an example for insertion into mail(). Did you try it?<?php
$subject = $namesen.' wants you to see you';
$charset = 'ISO-8859-1';
$subject_encoded = '=?' . $charset . '?B?' . base64_encode($subject) . '?=';
?>
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.