Scroll to see replies
<?PHP
if(!$_POST[send]){
?>
<form method="POST">
Your Email:<input type="email" name="email" class="textbox"><br />
<input name="send" type="submit" id="send" value="Send">
</form>
<?PHP
}else{
$emailaddress = $_POST;
$email = new PHPMailer();
$email->From = '[email protected]';
$email->FromName = 'Your Name';
$email->Subject = 'Message Subject';
$email->Body = $bodytext;
$email->AddAddress( '$emailaddress' );
$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
$email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
return $email->Send();
}
?>
1.
<?php
2.
// Multiple recipients
3.
$to = $_POST['email'];// note the comma
4.
// Subject
5.
$subject = 'Birthday Reminders for August';
6.
// Message
7.
$message = '
8.
<html>
9.
<head>
10.
<title>Birthday Reminders for August</title>
11.
</head>
12.
<body>
13.
sample text
14.
</body>
15.
</html>
16.
';
17.
// To send HTML mail, the Content-type header must be set
18.
$headers[] = 'MIME-Version: 1.0';
19.
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
20.
// Additional headers
21.
$headers[] = 'To: Mary <[email protected]>, Kelly <[email protected]>';
22.
$headers[] = 'From: Birthday Reminder <[email protected]>';
23.
$headers[] = 'Cc: [email protected]';
24.
$headers[] = 'Bcc: [email protected]';
25.
// Mail it
26.
if($_POST){
27.
mail($to, $subject, $message, implode("\r\n", $headers));
28.
}
29.
?>
<form action="email_script.php" method="post"> <label for="email">Enter your email below to receive newsletter</label>
<input type="text" name="email" id="email">
<button id="emailButton"> send me newsletter </button> </form>