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';
}
}
?>
No comments posted yet
Your Answer:
Login to answer
287
50
Other forums
Display the user's weight lost in the past week
Hello everyone,
I am working on a weight loss app for my site, and I want to display the user
Help pulling in 'id' with "read more" link
I'm trying to create snippets of my articles in the cms I'm creating, and then have them redirect to
user data not transferring to new page
I'm a PHP learner. After an index.php page, the user goes to a login.php page. Both pages seem to
Multi-image upload problems
Lets see if I can get some help on this one. Can anyone show me what I am doing wrong here. I'm just
Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages.
How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.
So today is 10/20/2009, i need to fig
Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne
How could I do this?
Ive got a simple lottery game, and am using an sql database to keep track of the numbers bought. But
Schedule editor
Hi,
I have a question related to Schedule editor.
If we schedule a BLS for every 30
download directory onto C drive
I am attempting (if this is possible) to write a routine to automatically dump the contents of a dir