How to install phpMailer in shared hosting environment? - phpmailer

How to install phpMailer in a shared hosting environment?
Seen this How to install phpMailer in a shared hosting environment? but I don't understand what does "include the main file with this line:" means and the next part too "After that, you will need an external SMTP account, like gmail.com for example. Here is a working example of PHPMailer with GMAIL:"
Thanks in advance
Athlios
This is the send_form.php
<?php
$formid = $_POST['contactform'];
$email_to = "info#a-wd.eu";
$fullname = $_POST['fullname']; // required
$email_from = $_POST['email']; // required
$subject = $_POST['subject']; // required
//$subjectselect = $_POST('subject').value();
$message = $_POST['message']; // required
echo($email_from);
$email_message = "Submission details below.\n\n";
$email_message .= "Fullname: ".clean_string($fullname)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Whats this about: ".clean_string($subject)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
$email_message = wordwrap($email_message, 70, "\r\n");
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message,$headers) or die("Error!");
echo "Thank you for contacting us. We will be in touch with you very soon. \r\n";
?>
This is the page
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="container contact-form-container">
<div class="row">
<div class="col-md-12">
<form action="send_form.php" id="contactform" name="contactform" method="post" data-parsley-validate>
<div class="row">
<!-- <span class="required-key">Fields marked with a <span class="label-required">*</span> are required.</span> -->
<div class="form-group col-lg-12 col-12">
<label for="fullname">Name <span>(Required)</span>:</label>
<input type="text" name="fullname" data-parsley-trigger="focusin focusout" required data-parsley-required="true" data-parsley-errors-messages-disabled />
</div>
<div class="form-group col-lg-12 col-12">
<label for="email">Email <span>(Required)</span>:</label>
<input type="email" data-parsley-type="email" name="email" data-parsley-trigger="focusin focusout" required data-parsley-required="true" data-parsley-errors-messages-disabled />
</div>
<div class="form-group col-lg-12 col-12">
<label for="subject">Subject <span>(Required)</span>:</label>
<select name="subject" required data-parsley-required="true" data-parsley-errors-messages-disabled>
<option value="question">General Question</option>
<option value="quote">Request a Quote</option>
<option value="sponsorship">Sponsorship</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group col-lg-12 col-12">
<label for="message">Message <span>(Required)</span>:</label>
<textarea name="message" data-parsley-trigger="focusin focusout" data-parsley-minlength="20" data-parsley-maxlength="1000" data-parsley-validation-threshold="10" data-parsley-minlength-message="Minimum message length is 20 characters" data-parsley-maxlength-message="Maximum message length is 1000 characters" data-parsley-required="true"></textarea>
</div>
<div class="form-group col-lg-12 col-12">
<label for="message">Captcha <span>(Required)</span>:</label>
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="6LeAAUkUAAAAAJeW7fjroLKFkYtETHvXGgflK49u"></div>
</div>
<div class="form-group col-lg-12 col-12">
<button class="btn-contact" name="send" type="submit">Send Message <i class="fa fa-paper-plane" aria-hidden="true"></i></button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Go to the PHPMailer github, click the green "Clone or Download" button, and click "Download ZIP". On your local computer, unarchive the ZIP file and upload the PHPMailer-master folder to your shared server's public_html directory.
Now, wherever you want to use PHPMailer, include the parts you need:
<?php
require '/path/to/PHPMailer-master/src/PHPMailer.php'; // Only file you REALLY need
require '/path/to/PHPMailer-master/src/Exception.php'; // If you want to debug
?>
You don't need an external SMTP account for this to work, as noted in the PHPMailer documentation. So in a script where you're sending out an email, your code should look something like this:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-master/src/PHPMailer.php'; // Only file you REALLY need
require 'PHPMailer-master/src/Exception.php'; // If you want to debug
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Recipients
$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');
//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$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';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>
This should be all you need to get started using PHPMailer on a shared server. Check out the project's README and look at some examples for a better understanding of all the awesomeness you get with this library.
Update for OP's code
Put the include code at the top of send_post.php:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-master/src/PHPMailer.php'; // Only file you REALLY need
require 'PHPMailer-master/src/Exception.php'; // If you want to debug
// Form details
$formid = $_POST['contactform'];
$email_to = "info#a-wd.eu";
$fullname = $_POST['fullname']; // required
$email_from = $_POST['email']; // required
$subject = $_POST['subject']; // required
$message = $_POST['message']; // required
$email_message = "Submission details below.\n\n";
$email_message .= "Fullname: ".clean_string($fullname)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Whats this about: ".clean_string($subject)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
$email_message = wordwrap($email_message, 70, "\r\n");
// No need to set headers here
// Replace the mail() function with PHPMailer
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Recipients
$mail->setFrom($email_from, 'From Name');
$mail->addAddress($email_to, $fullname); // Add the recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $email_message;
$mail->send();
echo "Thank you for contacting us. We will be in touch with you very soon. \r\n";
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

Related

Including multiple form fields via Nodemailer with Express and Node.js

I am trying to receive an e-mail everytime the user submits my contact form.
The form has the following fields:
- email
- subject
- name
- track
- number
- the message
However when the e-mail is sent I can only get whichever field I input into the "text" field under mail options. It won't work if I try to turn it into an array or object because it says the chunk needs to be a string.
How can I send more form fields than whatever I input into text? Here's my code:
Nodemailer POST Route :
app.post ("/contact" , urlencodedParser, function(req, res){
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'theemail',
pass: 'emailpassword' // naturally, replace both with your real credentials or an application-specific password
}
});
var subject = req.body.subject;
var email = req.body.email;
var data = [
req.body.name,
req.body.track,
req.body.number,
req.body.message,
]
const mailOptions = {
from: req.body.email,
subject: req.body.subject,
to: "theemail",
text: req.body.message,
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
res.render("../EN/views/contact-success");
});
Form HTML
<div class="fade-in serviceform text-center container form-group">
<form method ="POST" action = "/contact">
<p class=" text-center">Touring | Recording | Online sessions | Any other question</p>
<input type="email" name="email" class="contactform" placeholder=" E-mail" required>
<input type="text" name="subject" class="contactform" placeholder=" Subject" required>
<input type="text" name="name" class="contactform" placeholder=" First and last name" required>
<input type="text" name="track" class="contactform" placeholder=" Track Name" required>
<input type="number" name="number" class="contactform" placeholder=" +351919999999" required>
<textarea class="contactformtext" name="message" placeholder=" Write your message here." rows="3" required></textarea>
<div class="text-center">
<button type="submit" class="btn btn-outline-danger">Contact</button>
</div>
</form>
<div class ="text-center">
<a class="anchor" href="https://www.facebook.com/"><i class="fab fa-facebook-square"></i></a><a class="anchor" href="https://www.instagram.com//"><i class="fab fa-instagram"></i></a>
<p>Facebook | | Instagram </p>
</div>
```
just use the backticks it will considered itself as the string

hide pop up based on message under browser's Response tab

in pop up box, we are displaying login form. once user enter wrong email id or password, we are displaying message : Invalid login/pw , but once they enter correct details and click on login button, than user will be logged in.
but issue is pop up box will remain until we close the pop up manually with help of close button as in below image, but i want to hide the pop up box if login is successfull.
enter image description here
Once we click on login, under Response tab, if there is no message, than i want to hide the pop up, if there is message as success":false,"error":"Invalid login or password." , than i don't want to hide the pop up
enter image description here
I tried below code :
Html
<form>
//code for email and pw
<button onclick = "hideWindow()">Login</button>
</form>
Ajax
function hideWindow()
{
var username=jQuery( "#customusername" ).val();
var password=jQuery( "#custompassword" ).val();
url="";
new Ajax.Request(url, {
method: 'POST',
onFailure: function(response){
},
parameters: {
username: username,
password:password
},
onSuccess: function(response)
{
if(response.responseText=="")
{
//trigger to close popup
document.getElementById('something').style.display = 'none';
document.getElementById('ajaxlogin-mask').style.display = 'none';
}
}
});
}
edit
<div class="ajaxlogin-window" id="something">
<form>
<div class="content">
<ul class="form-list">
<li>
<input type="hidden" id="likeproduct_id" name="product_id" value=""/>
<label for="email" class="required"><em>*</em>Email</label>
<div class="input-box">
<input type="text" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" id="email" title="<?php echo $this->__('Email Address') ?>" />
</div>
</li>
<li>
<label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="login[password]" id="pass" title="<?php echo $this->__('Password') ?>" />
</div>
</li>
<?php echo $this->getChildHtml('form.additional.info'); ?>
</ul>
</div>
<div class="buttons-set">
<button onclick = "hideWindow()" type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2" ><span><span><?php echo $this->__('Login') ?></span></span></button>
</div>
</div>
As I can see there is some thing wrong with your ajax function try this out:
onSuccess: function(response)
{
document.getElementById('something').style.display = 'none';
document.getElementById('ajaxlogin-mask').style.display = 'none';
}
function hideWindow()
{
var db_username = 'ankit';
var db_password = 'password';
var username=jQuery( "#customusername" ).val();
var password=jQuery( "#custompassword" ).val();
if(username = db_username && password == db_password) {
jQuery('#something').hide();
}
else{
jQuery('#something').prepend('Wrong Cred ');
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ajaxlogin-window" id="something">
<form>
<div class="content">
<ul class="form-list">
<li>
<input type="hidden" id="likeproduct_id" name="product_id" value=""/>
<label for="email" class="required"><em>*</em>Email</label>
<div class="input-box">
<input type="text" name="login[username]" value="" id="email" title="Email Address" />
</div>
</li>
<li>
<label for="pass" class="required"><em>*</em>Password</label>
<div class="input-box">
<input type="password" name="login[password]" id="pass" title="Password" />
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<button onclick = "hideWindow()" type="submit" class="button" title="Login" name="send" id="send2" ><span><span>Login</span></span></button>
</div>
Please check the code instead of ajax call i have just added a if condition.
Hope it might help you
Thanks

Stripe Payment Confirmation - PHP

Hope some PHP gurus can help me out with this. I am creating a simple donation form to accept payments using Stripe. I have included my code here. The form works fine in terms of processing payments. However, the script is supposed to send a confirmation email to the donor, saying that their donation has been received, etc. The issue I am having is that the script does not send such a confirmation. I am using GoDaddy hosting and have checked that my MX records are correct. I ran test from my hosting account (with help of GoDaddy support) as well to see if there's any issue with the account itself. The tests showed no such issues. I have tried minor tweaks such as changing headers, adding <>, etc., but no luck.
Here's my code for config.php
<?php
return array(
'test-mode' => true,
'secret-key' => 'YOUR_SECRET_KEY',
'publishable-key' => 'YOUR_PUBLISHABLE_KEY',
'thank-you' => 'http://example.com/thank-you.html',
'email-from' => 'no-reply#example.com',
'email-bcc' => 'admin#example.com',
'email-subject' => 'Thank you for your donation!',
'email-message' => "Dear %name%,\n\nThank you for your order of %amount%."
);
Here's my code for index.php
<?php
require('lib/Stripe.php');
$config = require('config.php');
if ($config['test-mode'] && $_SERVER['HTTPS'] != 'on') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
exit;
}
if ($_POST) {
Stripe::setApiKey($config['secret-key']);
$token = $_POST['stripeToken'];
$first_name = $_POST['first-name'];
$last_name = $_POST['last-name'];
$name = $first_name . ' ' . $last_name;
$address = $_POST['address'] . "\n" . $_POST['city'] . ', ' . $_POST['state'] . ' ' . $_POST['zip'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$amount = (float) $_POST['amount'];
try {
if ( ! isset($_POST['stripeToken']) ) {
throw new Exception("The Stripe Token was not generated correctly");
}
// Charge the card
$donation = Stripe_Charge::create(array(
'card' => $token,
'description' => 'Donation by ' . $name . ' (' . $email . ')',
'amount' => $amount * 100,
'currency' => 'usd'
));
// Build and send the email
$headers = 'From: ' . $config['emaily-from'];
$headers .= "\r\nBcc: " . $config['emaily-bcc'] . "\r\n\r\n";
// Find and replace values
$find = array('%name%', '%amount%');
$replace = array($name, '$' . $amount);
$message = str_replace($find, $replace , $config['email-message']) . "\n\n";
$message .= 'Amount: $' . $amount . "\n";
$message .= 'Address: ' . $address . "\n";
$message .= 'Phone: ' . $phone . "\n";
$message .= 'Email: ' . $email . "\n";
$message .= 'Date: ' . date('M j, Y, g:ia', $donation['created']) . "\n";
$message .= 'Transaction ID: ' . $donation['id'] . "\n\n\n";
$subject = $config['email-subject'];
// Send it
if ( !$config['test-mode'] ) {
mail($email,$subject,$message,$headers);
}
// Forward to "Thank You" page
header('Location: ' . $config['thank-you']);
exit;
} catch (Exception $e) {
$error = $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stripe Payment Form</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all">
<script type="text/javascript" src="https://js.stripe.com/v2"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
Stripe.setPublishableKey('<?php echo $config['publishable-key'] ?>');
</script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div class="wrapper">
<h1>Stripe Payment Form</h1>
<p><strong>Thanks for donating!</strong></p>
<div class="messages">
<!-- Error messages go here go here -->
</div>
<form action="#" method="POST" class="donation-form">
<fieldset>
<legend>
Contact Information
</legend>
<div class="form-row form-first-name">
<label>First Name</label>
<input type="text" name="first-name" class="first-name text">
</div>
<div class="form-row form-last-name">
<label>Last Name</label>
<input type="text" name="last-name" class="last-name text">
</div>
<div class="form-row form-email">
<label>Email</label>
<input type="text" name="email" class="email text">
</div>
<div class="form-row form-phone">
<label>Phone</label>
<input type="text" name="phone" class="phone text">
</div>
<div class="form-row form-address">
<label>Address</label>
<textarea name="address" cols="30" rows="2" class="address text"></textarea>
</div>
<div class="form-row form-city">
<label>City</label>
<input type="text" name="city" class="city text">
</div>
<div class="form-row form-state">
<label>State</label>
<select name="state" class="state text">
<option value="AL">AL</option>
<option value="WY">WY</option>
</select>
</div>
<div class="form-row form-zip">
<label>Zip</label>
<input type="text" name="zip" class="zip text">
</div>
</fieldset>
<fieldset>
<legend>
Your Generous Donation
</legend>
<div class="form-row form-amount">
<label><input type="radio" name="amount" class="set- amount" value="25"> $25</label>
<label><input type="radio" name="amount" class="set-amount" value="100"> $100</label>
<label><input type="radio" name="amount" class="other-amount" value="0"> Other:</label> <input type="text" class="amount text" disabled>
</div>
<div class="form-row form-number">
<label>Card Number</label>
<input type="text" autocomplete="off" class="card-number text" value="4242424242424242">
</div>
<div class="form-row form-cvc">
<label>CVC</label>
<input type="text" autocomplete="off" class="card-cvc text" value="123">
</div>
<div class="form-row form-expiry">
<label>Expiration Date</label>
<select class="card-expiry-month text">
<option value="01" selected>January</option>
<option value="12">December</option>
</select>
<select class="card-expiry-year text">
<option value="2017" selected>2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
</select>
</div>
<div class="form-row form-submit">
<input type="submit" class="submit-button" value="Submit Donation">
</div>
</fieldset>
</form>
</div>
<script>if (window.Stripe) $('.donation-form').show()</script>
<noscript><p>JavaScript is required for the donation form.</p></noscript>
</body>
</html>
Any help is greatly appreciated.

PHPMailer body message empty error

using tutorials I pasted and filled the following PHPMailer php file and made the following html form. However after send the error appears "Message could not be sent.Mailer Error: Message body empty". Please help.
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'xxx#gmail.com';
$mail->Password = 'xxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('xxx#gmail.com', 'Joe User');
$mail->addReplyTo('info#example.com', 'Information');
$mail->addAttachment('/var/tmp/file.tar.gz');
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->From = $email;
$mail->FromName = $name;
$mail->Body = $message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
and here is the form
<form name="contactform" method="post" action="email.php">
<div class="input-text-container clear">
<input type="text" name="name" id="name" placeholder="Your Name"
class="input-text input-text-left">
<input type="text" name="email" id="email" placeholder="Your E-mail"
class="input-text input-text-right">
</div>
<textarea type="text" name="message" id="message" placeholder="Your
Message" class="textarea"></textarea>
<button type="submit" value="submit Form" class="submit">SUBMIT</button>
</form>
Your script seems to rely on request parameters being available as global variables. But this is a very uncommon (and insecure) practice.
Use $_POST['message'] instead $message and the message body should contain data from the form. Do the same for the other parameters.

Variable "to" address in PHP Mailer

I am trying to set the "to" address for an email sent via an html form utilizing phpmailer. The end goal is to utilize a droplist to let the user select which person they are contacting depending on their needs. However, as I don't know much about PHP I'm going step by step and am already stuck.
I'm using the example that came with the site I purchased, but trying to modify it to include a to field. Right now I'm simply trying to get a new variable to show up but have not succeeded. This is the HTML form I have in place right now:
<form name="contact" method="post" action="phpmailer.php" class="af-form" id="af-form">
<div class="af-outer af-required">
<div class="af-inner">
<label for="toemail" id="toemail_label">To Whom:</label>
<input type="text" name="toemail" id="toemail" size="30" value="" class="text-input span8"/>
<label class="error" for="toemail" id="toemail_error">To field is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="name" id="name_label">Your Name:</label>
<input type="text" name="name" id="name" size="30" value="" class="text-input span8"/>
<label class="error" for="name" id="name_error">Name is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="email" id="email_label">Your Email:</label>
<input type="text" name="email" id="email" size="30" value="" class="text-input span8"/>
<label class="error" for="email" id="email_error">Email is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-message" id="message_label">Your Message:</label>
<textarea name="message" id="input-message" cols="30" class="text-input span8"></textarea>
<label class="error" for="input-message" id="message_error">Message is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<input type="submit" name="submit" class="form-button btn btn-large" id="submit_btn" value="Send Message!" />
</div>
</div>
The name, email, and message fields get picked up fine and populate in the email I recieve. However, the "toemail" field doesn't show up. Here is the process.php I am using for phpmailer.
<?php
if ((isset($_POST['toemail'])) && (strlen(trim($_POST['toemail'])) > 0)) {
$toemail = stripslashes(strip_tags($_POST['toemail']));
} else {$toemail = 'No to address entered';}
if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) {
$name = stripslashes(strip_tags($_POST['name']));
} else {$name = 'No name entered';}
if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) {
$email = stripslashes(strip_tags($_POST['email']));
} else {$email = 'No email entered';}
if ((isset($_POST['message'])) && (strlen(trim($_POST['message'])) > 0)) {
$message = stripslashes(strip_tags($_POST['message']));
} else {$message = 'No phone entered';}
ob_start();d
?>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<table width="550" border="1" cellspacing="2" cellpadding="2">
<tr bgcolor="#eeffee">
<td>To Whom:</td>
<td><?=$toemail;?></td>
</tr>
<tr bgcolor="#eeffee">
<td>Name</td>
<td><?=$name;?></td>
</tr>
<tr bgcolor="#eeeeff">
<td>Email</td>
<td><?=$email;?></td>
</tr>
<tr bgcolor="#eeffee">
<td>Message</td>
<td><?=$message;?></td>
</tr>
</table>
</body>
</html>
<?
$body = ob_get_contents();
$to = 'personalemailtousefortesting.com';
$email = 'email#example.com';
$fromaddress = "you#example.com";
$fromname = "Online Contact";
require("phpmailer.php");
$mail = new PHPMailer();
$mail->From = "mail#yourdomain.com";
$mail->FromName = "Contact Form";
$mail->AddAddress("mypersonalemailfortestingpurposes#gmail.com","Name 1"); // addresses here
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Contact form submitted";
$mail->Body = $body;
$mail->AltBody = "This is the text-only body";
if(!$mail->Send()) {
$recipient = 'mypersonalemailfortestingpurposes#gmail.com';
$subject = 'Contact form failed';
$content = $body;
mail($recipient, $subject, $content, "From: mail#yourdomain.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
exit;
}
?>
The email I get populates the name, email, and message fields fine, however, I get my fall back error message of 'No to address entered' for the "toemail" input.
This is issue number one. I'll post the phpmailer.php that I'm using if anyone needs to see it. I do not know if I need to define the variable in there first.
After I get that working, I need to make it work for a dropdown list so the user cannot just send the email to whomever they would like.
THEN, I need to set that as the actual send-to address. I do not know how to set the actual address for sending purposes. I would assume that I change
$mail->AddAddress("mypersonalemailfortestingpurposes#gmail.com","Name 1"); // addresses here
to something like...
$mail->AddAddress($toemail,"Name 1"); // addresses here
...but odds are that's not correct.
Any help you can provide would be wonderful.
If you need to see my phpmailer.php I can post that too.
Thanks again,
-Rocky Colt TumTum
Just incase you didn't find this, this is what was listed on the PHP Manual site.
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>

Resources