<?php
ini_set('error_reporting', E_ALL);
if($_POST['send_mail']) {
if($_POST['email']) {
function sendmsg($email_to, $email_subject, $msgtext, $email_from, $email_replyto, $file, $type){
require_once("htmlMimeMail.php");
$filename = basename($file);
$mail = new htmlMimeMail();
$mail->setFrom("$email_from");
$mail->setReturnPath("$email_replyto");
$mail->setSubject("$email_subject");
$mail->setHTML("$msgtext");
$mail->addAttachment($mail->getFile("$file"), "$filename", 'application/pdf');
$result = $mail->send(array("$email_to"));
return $result ? 'Mail sent successfully!' : 'Sorry! Cannot send the mail. Try later!';
}
$fileatt = "test.pdf";
$subject = 'Sending Mail using HTMLMimeMail';
$to = $_POST['email'];
$email_from = 'satheesh@iv.bh';
$email_replyto = 'satheesh@iv.bh';
$type = 'application/pdf';
$ok = sendmsg($to, $subject, $msg,$email_from,$email_replyto, $fileatt, $type);
echo $ok;
}
else echo 'Please enter Email';
}else echo 'Please enter Email';
?>
<form action="" method="POST">
<input type="text" name = "email"><br>
<input type="submit" value="Send Mail" name="send_mail">
</form>
No comments:
Post a Comment