need help with mail()
Posted on
16th Feb 2014 07:03 pm by
admin
hi i want to send an email with attaching pdf file using php. i have the following script but the problem with this is when i send an attachment it does to the specified address but that email is empty means there is no attachment as well as message. what i am doing wrong in this script help
Code: <form id="requestcv" name="form1" method="post" action="request2.php">
<div>
<label>Your Name:</label>
<input type="text" name="name" id="textfield" />
</div>
<div>
<label>Your Email:</label>
<input type="text" name="email" id="textfield2" />
</div>
<div class="actions">
<input class="actions" type="submit" name="request" id="button" value="Request CV" />
</div>
</form>
<p>
<?php
if($_POST['request'])
{
//echo "My cv has been sent to your email address.Please check your email after 15 minutes. Thank you for requesting my CV.";
$name = $_POST['name'];
$email = $_POST['email'];
$message = "Here is my CV you requested for.Please download attachment and view my cv.Thank you for using my services.";
$to = $email;
$subject = "This is from zafar portfolio";
$random_hash = md5(date('r', time()));
$headers = "From: address@yahoo.comrnReply-To: address@yahoo.com";
$headers .= "rnContent-Type: multipart/mixed; boundary="PHP-mixed-".$random_hash.""";
$attachment = chunk_split(base64_encode(file_get_contents("CV.pdf")));
$output = "
--PHP-mixed-$random_hash;
Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
--PHP-alt-$random_hash
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Hello World!
This is the simple text version of the email message.
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is the <b>HTML</b> version of the email message.</p>
--PHP-alt-$random_hash--
--PHP-mixed-$random_hash
Content-Type: application/pdf; name=CV.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
//mail($to, $subject, $message, $output, $headers);
if (mail($to, $subject,$message, $output, $headers)) {
echo 'Mail sent';
} else {
echo 'Mail NOT sent';
}
}
?>
287
50
Other php-forum
Will this protect from mysql injection?
I do not want anything like DROP TABLE to work or any type of coding..
Heres my code.. is it
using file_get_contents??
okay how would i create a script using file_get_contents() in php have it grab search pages 1-20 and
couldn't connect to your database
Hello I am new to php mysql
Actually i have read A tutorial on nettuts
"http://net.tu
help retrieiving results and doing pagination
Having some trouble trying to get the results to show on more than just one page.
What is ha
word wrap in emails help needed
Hello, I understand how wordwrap works in php and have used it well before. However when I used wor
query based on 2 conditions
I want to select if the doc_type is either s OR f but this doesn't work:
Code: [Select]$query
Progress bar tracking file downloads
Hey guys, was wondering if there was a way to track how far a file has been downloaded. I know there
why preg_match_all does not return the number of matches
My regex looks like
X[^x{4e00}-x{9fa5}]*Y
(where X and Y are two Chinese characters)
PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) a
How do I get the row number from from an sql table query
Hi all
I have a table that I query and it returns a number of rows.
mysql_num_rows($query)