sending emails when a form is submitted [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
im trying to make it so that when a form is submitted, it would send an email. The database connecting/submitting is working so it's nothing from the database or form side hopefully.
Here is my code:
<?php
$mysql_host = "localhost";
$mysql_username = "";
$mysql_password = "";
$mysql_database = "";
$mysql_database2 = "";
$sub = $_POST['subject'];
$mysqli2 = new Mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database2) or die(mysqli_error());
$head = $mysqli2->query("SELECT head FROM class WHERE subject = '$sub'")->fetch_object()->head;
$status = 1;
$mysqli = new Mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database) or die(mysqli_error());
$prepare = $mysqli->prepare("INSERT INTO `Overrides`(`name`,`mname`,`fname`,`sid`,`email`,`phone`,`sc`,`subject`,`section`,`semester`,`professor`,`status`,`dean`,`head`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$prepare->bind_param("ssssssssssssss", $_POST['name'], $_POST['mname'], $_POST['fname'], $_POST['sid'], $_POST['email'], $_POST['phone'], $_POST['Scolarship'], $_POST['subject'], $_POST['section'], $_POST['semester'], $_POST['professor'], $status, $_POST['dean'], $head);
$prepare->execute();
$name = $_POST['name'];
$mname= $_POST['mname'];
$fname = $_POST['fname'];
$email = $_POST['email'];
$semester = $_POST['semester'];
$sid = $_POST['sid'];
$subject = $_POST['subject'];
$section = $_POST['section'];
$professor = $_POST['professor'];
if(prepare)
{
$to = '$email'; //can receive notification
$subject = 'Override Request';
$message = 'Dear $name<br /><br />
Your Following override request has been submitted.<br /><br />
Name: $name . $mname . $fname
Student ID : $sid
Semester : $semester
Subject : $subject
Section : $section
Professor : $professor<br /><br />
Please note that the request is passed to different faculty members in order to be revised. You will be notified on each update';
$headers = 'From: system#auke.edu.kw' . "\r\n" .
'Reply-To: webmaster#ourcompany.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
print 'Error : ('. $mysqli->errno .') '. $mysqli->error;
?>
It prints email sent but i get nothing on my mail.
Thanks.

$to = '$email';
Have to be
$to = "$email";
or - better:
$to = $email;

You should read this Curly braces in string in PHP
In your code "Email sent" will be allways display.
Try:
if ( mail($to, $subject, $message, $headers) )
echo "Sent";
else
echo "Error";

One of the problems is here
if(prepare)
prepare is treated as a constant rather than the intended variable $prepare.
Do if($prepare){...}
Also your variables need to be in double quotes.
$to = '$email';
variables do not get interpolated in single quotes
$to = "$email";
same for $message = '...'; that should be $message = "...";
You should also be doing and replacing $prepare->execute(); with
if(!$prepare->execute()){
trigger_error("there was an error....".$mysqli->error, E_USER_WARNING);
}
or
if(!$prepare->execute()){
trigger_error("there was an error....".$mysqli2->error, E_USER_WARNING);
}
for your SELECT connection.
to check for possible db errors.
Also make sure your form uses a POST method and that all elements bear the proper name attributes.
Form will fail silently if the POST method is omitted.
It also defaults to GET if omitted. I don't know what the form looks like, so you'll need to look into that.
Edit: (adding PHPmailer information)
Seeing as you may not have access to using mail(), you could try using PHPmailer and a Gmail account if you have one.
Here is an example pulled from https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
Visit also their main page: http://phpmailer.worxware.com/index.php
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "username#gmail.com";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('from#example.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto#example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto#example.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

Related

Use array of emails and names from database in PHPMailer

I'm using PHPMailer to send an email from a form to all the emails in a MySQL database.
I've managed to get the form to send an email to each email but I'm now trying to use their name in the email sent to them meaning each email woud begin with "Hello, [their-name],".
I'm using an array to loop through the results of my database query and adding each email and name as $mail->addAddress('email#email.com, 'name');
I've tried saving the variable $name = $row['name'}; inside the while loop but it inputs the last name from the database into all the emails.
My question is: Is it possible to access the 'name' part of the function and use it each email. Or is it better to take their name from the database itself? And if so how would I go about doing that?
Also, when the email sends to each recipient, it shows all of the recipients in the "To:" field. This would be pretty bad for privacy. Is there a way to prevent this?
I'm fairly new to PHP and MySQL still so explanatory answers would be greatly appreciated.
Please find my code below.
<?php
// Take message value from form
$message = preg_replace("/\r\n|\r/", "<br />", $_REQUEST['message']);
$message = trim($message);
// Error reporting on
error_reporting(E_STRICT | E_ALL);
date_default_timezone_set('Etc/UTC');
// Require PHPMailer
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Port = 587;
$mail->Username = 'my#email.com';
$mail->Password = 'mypassword';
$mail->setFrom('myemail#email.com', 'Me');
$mail->addReplyTo('myemail#email.com', 'Me');
$mail->Subject = "Newsletter";
/* ----- Add address function below ----- */
// Require Database connection
require 'dbcon.php';
// SELECT email and name values from database
$query = "SELECT email, name FROM customers";
// Result = the database query
$result = $con->query($query);
// Get array of users email addresses and names.
while($row = $result->fetch_array())
{
// Add recipients from values found in database
$mail->addAddress($row["email"], $row["name"]);
}
/* ----- Add address function above ----- */
$mail->Body ="Hello, <br> <br> $message";
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent.";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
print 'Sent!';
?>
You are currently setting up to send a single email with several recipients. For security and etiquette, you should address the email to yourself (outside the loop):
$mail->addAddress('myemail#email.com', 'Me');
...and then add all of the recipients as BCC (inside the loop):
$mail->addBCC($row["email"], $row["name"]);
As for the name field. Add a debug line inside your loop and take a look at your output. Is the name field the same each time?
print "Adding recipient: {$row['email']} {$row['name']}";
If you want to sent several emails, one to each recipient, you need to instantiate a new email inside the loop each time.
[UPDATE]
If you want to send a single message to each recipient, then instantiate a new email each time (inside your loop):
<?php
// Take message value from form
$message = preg_replace("/\r\n|\r/", "<br />", $_REQUEST['message']);
$message = trim($message);
// Error reporting on
error_reporting(E_STRICT | E_ALL);
date_default_timezone_set('Etc/UTC');
// Require PHPMailer
require 'PHPMailer/PHPMailerAutoload.php';
// Require Database connection
require 'dbcon.php';
// SELECT email and name values from database
$query = "SELECT email, name FROM customers";
// Result = the database query
$result = $con->query($query);
// Get array of users email addresses and names.
while($row = $result->fetch_array())
{
// Instantiate a NEW email
$mail = new PHPMailer;
// Set the email settings
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Port = 587;
$mail->Username = 'my#email.com';
$mail->Password = 'mypassword';
$mail->setFrom('myemail#email.com', 'Me');
$mail->addReplyTo('myemail#email.com', 'Me');
$mail->Subject = "Newsletter";
// Add recipient from values found in database
$mail->addAddress($row["email"], $row["name"]);
$mail->Body ="Hello, <br> <br> $message";
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent.";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
print "Sent mail to: {$row["email"]}, {$row["name"]}";
}
?>

Fatal Error in PHPMailer

A beginner here.
I have already checked the forum to find out answers but I was not successful, other questions were specifically on some parts of PHPMailer but mine is more general. So I hope no one will mark my question as duplicate as I am in learning curve.
I am working on a PHP project. How it works is that the user goes to the page and writes some comments or issues in a form (like a text editor) and clicks on the send button. I should be able to receive his message to my email. I have set my Gmail account here for testing purposes but later it will be my real email with my own domain.
Here is the error that I am receiving when I run on local host:
Fatal error: Uncaught exception 'phpmailerException' with message 'Could not execute: /usr/sbin/sendmail' in C:\xampp\htdocs\pp\classes\class.phpmailer.php:1100 Stack trace: #0 C:\xampp\htdocs\pp\classes\class.phpmailer.php(1026): PHPMailer->sendmailSend('Date: Thu, 9 Oc...', '--b1_9ea0b33e3f...') #1 C:\xampp\htdocs\pp\classes\class.phpmailer.php(935): PHPMailer->postSend() #2
Here is the code I am using:
<?php
require_once("../../classes/class.phpmailer.php");
if($_POST['mode']=='send'){
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSendmail(); // telling the class to use SendMail transport
//I assume this part is to make it run on linux base on Google search
$body = "New Bug Report from ".$_SESSION['name']."\n".$_POST['bug'];
$mail->AddReplyTo('mj#gmail.com', 'MJ Team');
$mail->AddAddress(''.$_SESSION['email'].'', ''.$_SESSION['name'].'');
$mail->SetFrom(mj#gmail.com', 'MJ Team');
$mail->AddReplyTo('mj#gmail.com', 'MJ Team');
$mail->Subject = 'New bug report for the portal';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($body);
$mail->Send();
//And I assume this part of the code makes it run on windows based on Google search
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.postmarkapp.com";
$mail->Port = 26;
$mail->Username = "MJ";
$mail->Password = "MJ";
$mail->SetFrom('mj#gmail.com', 'mj');
$mail->Subject = "An email for test";
$mail->AddAddress($address, $name);
if($mail){
$message = 'Thanks. Bug report successfully sent. We will get in touch if we have any more questions.';
}
else {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
?>
Just as extra information I was not able to find any user and pass for SMTP so I just filled with with my name which obviously shouldn't be right.
Since I am beginner I appreciate any comments and suggestion code that might help me run my code.
Thank you!
Try this :
<?php
session_start();
if(isset($_POST['mode']) && $_POST['mode']=='send' &&
isset($_SESSION['email'], $_SESSION['name'])){
require_once("PHPMailerAutoload.php");
$mail = new PHPMailer(true);
//Send mail using gmail
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "mj#gmail.com"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
//Typical mail data
$mail->AddAddress($_SESSION['email'], $_SESSION['name']);
$mail->SetFrom('mj#gmail.com', 'mj');
$mail->Subject = "This is a test message";
$mail->Body = "An email for test";
try{
$mail->Send();
echo "Thanks. Bug report successfully sent.
We will get in touch if we have any more questions!";
} catch(Exception $e){
//Something went bad
echo "Mailer Error: - " . $mail->ErrorInfo;
}
}else{
echo 'missing required values!';
}
If all you want to do is send an email why not use the PHP Mail command (http://php.net/manual/en/function.mail.php)
replace your code with this:
$to = 'mj#gmail.com';
$subject = 'the subject';
$message = 'New bug report for the portal';
$headers = 'From: mj#gmail.com' . "\r\n" .
'Reply-To: mj#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

Sending multiple emails with PHPmailer

Edit: I forgot I'd created the SendMail(); function myself, which is why the explanation doesn't mention at first what it does.
I'm having some trouble with PHPMailer (https://github.com/PHPMailer/PHPMailer) when attempting to send two emails, one directly after the other.
The script is almost completely 'out of the box', with only a few modifications such as a foreach loop to allow for multiple addresses, and everything still works perfectly.
However, if I attempt to call more than one instance of SendMail(); I get the error message:
Fatal error: Cannot override final method Exception::__clone() in .... online 0
Previously I was using the in-built mail(); function, which allowed me to use it as many times as I liked in quick succession , but it doesn't appear to be that simple with PHPmailer:
$to = me#me.com;
$to2 = me2#me2.com';
$headers = 'php headers etc';
$subject = 'generic subject';
$message = 'generic message';
mail($to, $subject, $message, $headers);
mail($to2, $subject, $message, $headers);
The above would result in two identical emails being sent to different people, however I can't easily replicate this functionality with PHPmailer.
Is there a way of stacking these requests so that I can send successive emails without it failing? Forcing the script to wait until the first email has been sent would also be acceptable, although not preferential.
As I mentioned I know it works when only one instance is called, but I don't seem to be able to re-use the function.
I haven't included the source code, although it is all available on the link provided above.
Thanks in advance
Edit as requested
// First Email
$to = array(
'test#test.com',
'test2#test.com',);
$subject = "Subject";
$message = $message_start.$message_ONE.$message_end;
sendMail();
// Second Email
$to = array(
'test#test.com',
'test2#test.com',);
$subject = "Subject";
$message = $message_start.$message_TWO.$message_end;
sendMail();
The above is how I want this to work, as it would work with mail();. The first email will work fine, the second will not.
SendMail() code
This is from the PHPmailer website, and is what is defined as SendMail();. The only difference from the example is the loop for AddAddress, and the inclusion of $to as a global variable.
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from#example.com";
$mail->FromName = "Mailer";
foreach($to as $to_add){
$mail->AddAddress($to_add); // name is optional
}
$mail->AddReplyTo("info#example.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
$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. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
You haven't posted this code that lets me make this a complete conclusion, but from the Exception and the way you've defined an overriding class inside a function, you probably have class.phpmailer.php loading every time like this:
require('class.phpmailer.php');
or
include('class.phpmailer.php');
You should change that line to
require_once('class.phpmailer.php');
The reason you need to change it to require_once is so that PHP will not load the class file the second time when you try to create the new/second PHPMailer class. Otherwise, the line class PHPMailer throws the __clone() exception.
Added an example below:
<?php
/**
* This example shows how to send a message to a whole list of recipients efficiently.
*/
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
error_reporting(E_STRICT | E_ALL);
date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php';
//Passing `true` enables PHPMailer exceptions
$mail = new PHPMailer(true);
$body = file_get_contents('contents.html');
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Port = 25;
$mail->Username = 'yourname#example.com';
$mail->Password = 'yourpassword';
$mail->setFrom('list#example.com', 'List manager');
$mail->addReplyTo('list#example.com', 'List manager');
$mail->Subject = 'PHPMailer Simple database mailing list test';
//Same body for all messages, so set this before the sending loop
//If you generate a different body for each recipient (e.g. you're using a templating system),
//set it inside the loop
$mail->msgHTML($body);
//msgHTML also sets AltBody, but if you want a custom one, set it afterwards
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
//Connect to the database and select the recipients from your mailing list that have not yet been sent to
//You'll need to alter this to match your database
$mysql = mysqli_connect('localhost', 'username', 'password');
mysqli_select_db($mysql, 'mydb');
$result = mysqli_query($mysql, 'SELECT full_name, email, photo FROM mailinglist WHERE sent = FALSE');
foreach ($result as $row) {
try {
$mail->addAddress($row['email'], $row['full_name']);
} catch (Exception $e) {
echo 'Invalid address skipped: ' . htmlspecialchars($row['email']) . '<br>';
continue;
}
if (!empty($row['photo'])) {
//Assumes the image data is stored in the DB
$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
}
try {
$mail->send();
echo 'Message sent to :' . htmlspecialchars($row['full_name']) . ' (' . htmlspecialchars($row['email']) . ')<br>';
//Mark it as sent in the DB
mysqli_query(
$mysql,
"UPDATE mailinglist SET sent = TRUE WHERE email = '" .
mysqli_real_escape_string($mysql, $row['email']) . "'"
);
} catch (Exception $e) {
echo 'Mailer Error (' . htmlspecialchars($row['email']) . ') ' . $mail->ErrorInfo . '<br>';
//Reset the connection to abort sending this message
//The loop will continue trying to send to the rest of the list
$mail->getSMTPInstance()->reset();
}
//Clear all addresses and attachments for the next iteration
$mail->clearAddresses();
$mail->clearAttachments();
}
In addition to #Amr most excellent code.
In order to use this in a cron fasion, two adds are useful.
$mail-> SMTPDebug = true;
$mail-> Debugoutput = function( $str, $level ) {_log($str);};
The function _log is up to you. Writing to a file, to a database or wherever. I personally have reduced this to
$mail-> Debugoutput = function( $str, $level ) {if( $level===3 ) {_log( $str ); } };
to only write the more juicier messages
the solution is to reset recipients data like this:
$Mailer->clearAddresses()
use your own variable as an instance of PHPMailer (instead of $Mailer)
$Mailer->clearAddresses()
This is the solution to avoid multiple msj to be send to the same recipient.

PHPMail - can I send two unique emails

I'm using PHPMailer to successfully send an email upon a webform submission (so just using basic post data, no mysql databases or any lookups).
What I need to do is send two seperate emails, one version for the customer and the other for a customer service agent - so that when a user completes a webform, they will receive a 'marketing' version of the email, whilst the customer service agent will receive an email just containing the details submitted by the user.
See below what im using at the moment, but not sure how to best implement to send the secoind email? It presently fails and the script exits after sending only one email.
$body = ob_get_contents();
$to = 'removed';
$email = 'removed';
$fromaddress = "removed";
$fromname = "removed";
require("phpmailer.php");
$mail = new PHPMailer();
$mail->From = $fromaddress;
$mail->FromName = $fromname ;
$mail->AddAddress("email#example.com");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Subject";
$mail->Body = $body;
$mail->AltBody = "This is the text-only body";
if(!$mail->Send()) {
$recipient = 'email#example.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;
}
//Send the customer version
$mail=new PHPMailer();
$mail->SetFrom('email', 'FULLNAME');
$mail->AddAddress($mail_vars[2], 'sss');
$mail->Subject = "Customers email";
$mail->MsgHTML("email body here");
//$mail->Send();
In the customer version you are not setting the email's properties the same way you are in the first. For example you use $mail->From = $fromaddress; in the first and $mail->SetFrom('email', 'FULLNAME'); in the second.
Because you instantiated a new $mail=new PHPMailer(); you need to set the properties again.
Instead of just bailing out with a useless "something didn't work" message, why not have PHPMailer TELL you what the problem is?
if (!$mail->send()) {
$error = $mail->ErrorInfo;
echo "Mail failed with error: $error";
}

Invalid Address in PHPMailer

I'm getting an invalid address error while running the PHP script below. The SMTP credentials and recipient e-mail were altered for this post. They are all valid on the actual script. I don't know why the recipient e-mail is being rejected. I'm trying to send an e-mail with SMTP authentication, and SMTP security (SSL, TLS) is not required.
Any help would be appreciated.
include 'PHPMailer_5.2.2/class.phpmailer.php';
function SendConfirmation ($sName, $sEmail)
{
$mail = new PHPMailer ();
$mail->SMTPDebug = 2;
$mail->Host = "mail.exchange.telus.com";
$mail->IsSMTP ();
$mail->Username = "inbin#website.com";
$mail->Password = "password";
$mail->From = "inbin#website.com";
$mail->FromName = "Web Site";
$mail->AddAddress ($sEmail, $sName);
$mail->Subject = 'PHPMailer Test' . date ('Y-m-d H:i:s');
$mail->Body = "This is a test.";
if ($mail->Send ())
echo "\r\nMail sent.";
else
echo "\r\nMail not sent. " . $mail->ErrorInfo;
echo "\r\n";
}
/***[ Main ] **************************************************************************/
$sName = 'Johan Cyprich';
$sEmail = 'jcyprich#website.com';
$bSent = SendConfirmation ($sName, $sEmail);
Make sure you have valid email addresses for AddReplyTo and/or AddAddress.
I had the same problem and it turned out to be because I was setting empty values for AddReplyTo.

Categories