php 邮件mailto phpmailer电子邮件表格附件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 邮件mailto phpmailer电子邮件表格附件相关的知识,希望对你有一定的参考价值。
http://blog.chapagain.com.np/php-easily-send-email-with-phpmailer/
<?php
/*For Magento */
require_once BP . DS . 'class.phpmailer.php';
/*For WP */
require_once('class.phpmailer.php');
if(isset($_REQUEST['submit-your-story']) && !empty($_REQUEST['submit-your-story']))
{
$firstname = $_REQUEST['story-firstname'];
$lastname = $_REQUEST['story-lastname'];
$email = $_REQUEST['story-email'];
$title = $_REQUEST['story-title'];
$phone = $_REQUEST['story-phone'];
$story = $_REQUEST['story'];
$images = $_FILES;
$mail = new PHPMailer();
$body .= 'First Name : '.$firstname.'<br />';
$body .= 'Last Name : '.$lastname.'<br />';
$body .= 'Email : '.$email.'<br />';
$body .= 'Title : '.$title.'<br />';
$body .= 'Phone : '.$phone.'<br />';
$body .= 'Story : '.$story.'<br />';
$mail->SetFrom($email, $firstname);
$mail->AddReplyTo($email, $firstname);
$address = "dmitriy.kryuchko@w3.ua";
$mail->AddAddress($address, "Deed Carrier (Submit Your Story) ");
$mail->Subject = 'Deed Carrier (Submit Your Story) '.$title;
$mail->MsgHTML($body);
/*For Magento */
$baseDir = BP . DS . 'uploads/';
/*For WP */
$baseDir = $_SERVER['DOCUMENT_ROOT'] . '/deedcarrier/uploads/';
foreach($images as $image)
{
if(!empty($image['tmp_name']))
{
/*Move From temp directory to directory in your theme */
move_uploaded_file($image['tmp_name'], $baseDir.$image["name"]);
$mail->AddAttachment($baseDir.$image["name"], $image["name"]);
}
}
if(!$mail->Send()) {
echo "<div class=\"form-error\">Mailer Error: " . $mail->ErrorInfo."</div>";
} else {
echo "<div class=\"form-success\">"."Thank you! Your message has been successfully sent."."</div>";
}
}
?>
<form action="" name="submit-your-story-form" enctype="multipart/form-data" method="post">
<fieldset>
<input type="hidden" name="submit-your-story" value="1" />
<div class="row">
<div class="field field-col">
<label for="story-firstname"><?php echo $this->__('first name'); ?> <em>*</em></label>
<div class="input-text">
<input type="text" id="story-firstname" name="story-firstname" value="<?php echo $first_name; ?>" placeholder="<?php echo $first_name; ?>" />
</div>
</div>
<div class="field field-col field-col-alt">
<label for="story-lastname"><?php echo $this->__('Last name'); ?> <em>*</em></label>
<div class="input-text">
<input type="text" id="story-lastname" name="story-lastname" value="<?php echo $last_name; ?>" placeholder="<?php echo $last_name; ?>" />
</div>
</div>
</div>
<div class="row">
<div class="field">
<label for="story-email"><?php echo $this->__('email address'); ?> <em>*</em></label>
<div class="input-text">
<input type="email" name="story-email" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" id="story-email" />
</div>
</div>
</div>
<div class="row">
<div class="field">
<label for="story-title"><?php echo $this->__('Story title'); ?> <em>*</em></label>
<div class="input-text">
<input type="text" id="story-title" name="story-title" />
</div>
</div>
</div>
<div class="row">
<div class="field">
<label for="story-phone"><?php echo $this->__('Phone Number'); ?> <em>*</em></label>
<div class="input-text">
<input type="tel" id="story-phone" name="story-phone" />
</div>
</div>
</div>
<div class="row">
<label for="story"><?php echo $this->__('your Story'); ?> <em>*</em></label>
<textarea id="story" cols="30" rows="10" name="story"></textarea>
<span class="note"><?php echo $this->__('500 Characters Remaining'); ?></span>
</div>
<div class="row row-file">
<label for="story-image1"><?php echo $this->__('image 1'); ?> <em>*</em></label>
<input id="story-image1" type="file" name="image1" />
</div>
<div class="row row-file">
<label for="story-image2"><?php echo $this->__('image 2'); ?></label>
<input id="story-image2" name="image2" type="file" />
</div>
<div class="row row-file">
<label for="story-image3"><?php echo $this->__('image 3'); ?></label>
<input id="story-image3" name="image3" type="file" />
</div>
<p class="required"><em>*</em> <?php echo $this->__('Required fields'); ?></p>
<div class="row-btn">
<input type="submit" value="<?php echo $this->__('Submit story'); ?>" />
</div>
</fieldset>
</form>
以上是关于php 邮件mailto phpmailer电子邮件表格附件的主要内容,如果未能解决你的问题,请参考以下文章