-1

I have a job portal website that is designed in blogger. I want user Upload resume send to my email. Here is my code.

<form action="https://examples.webscript.io/attachments/file"
    method="post" enctype="multipart/form-data">
    <input type="text" name="email" value="rajkumar23@gmail.com" style="display:none;"/>
   
    <input type="file" name="attachment" />
    <button type="submit">Upload</button>
</form>
 
<script type="text/javascript">
local SERVER = '<SMTP SERVER>'
local USERNAME = '<SMTP USERNAME>'
local PASSWORD = '<SMTP PASSWORD>'
 
email.send {
    server=SERVER, username=USERNAME, password=PASSWORD,
    from='hello@webscript.io',
    to=rajkumar23@gmail.com,
    subject='Webscript demo: file attachment',
    text='This is an automated email from a Webscript example. '..
  '(https://www.webscript.io/script/examples/attachments/file)',
    attachments = { request.files.attachment }
}
return "Email sent."
</script>

After send the file it shows 500 internal server error. How to solve this issue. Is there any code without using php. I want to design file in html and javascript. In blogger php script is not support.

narendra
  • 9
  • 2
  • 11

1 Answers1

-1

Use bellow maintained library :

https://github.com/PHPMailer/PHPMailer

and code will be

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'user@example.com';                 // SMTP username
$mail->Password = 'secret';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
$mail->addAddress('ellen@example.com');               // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
Om R Kattimani
  • 105
  • 1
  • 9