how to solve cannot send more than 16 receipts using php mailer? - phpmailer

Code
if ($redirectemail == "")
{
$mail->Body = $body;
$emailListArr = preg_split("/[;,]/", $toemail);
foreach ($emailListArr as $emailAdd) {
$mail->AddAddress(trim($emailAdd));
}
}
Error
cannot send more than 16 receipts using php mailer

Related

Here is the code for the PHPMailer and ImprovMX

Below is the code for the PHPMailer and ImprovMX. I have tried to use this code below so I can connect to ImprovMX and us a mail forward. The mx record was updated successfully but still it don't send via mail forward. I am using infinityfree hosting and they said this is not an issuse as you can use PHPMailer because they don't allow mail forwarding on free hosting.enter code here
<?php
$result = "";
if(isset($_POST['send'])){
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->isSMTP();
//$mail->Host = 'smtp.yandex.com';
//$mail->Port = 465;
//$mail->SMTPAuth = true;
//$mail->SMTPSecure = 'ssl';
//$mail->SMTPDebug = 3;
//personal info
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$body = $_POST['message'];
//end of input info
$mail->setFrom('info#domain.cf');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $email . "<br>" . $phone . "<br>" .
$body;
if(!$mail->send()){
$result = 'Message not sent. Please try again';
}else{
$result = 'Message sent. We will respond to you as soon as possible';
}
header("Location:index.php");
}
?>

AddStringAttachment giving unusual results

I am sending attachments (CSV) which I have been sending for years using mail() but decided to migrate to SMTP for better reliability.
Code 1 (CSV attachment)
$attachment = $this->CSVData; // "Date","Name","Dept" ... \n"2019-03-13","Dave" ...
$encoding = 'base64';
$contentType = 'text/csv';
$filename = $this->createFileName(); //Get FileDate and Name
$recipient = $delivery_email; // xxxxxxx#gmail.com
$subject = $this->emailHeader['subject'] . " CSV Data";
$message = 'Daily Data File';
$mail = new PHPMailer\PHPMailer\PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = SMTP_HOST; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = SMTP_USER; // SMTP username
$mail->Password = SMTP_PASS; // SMTP password
$mail->SMTPSecure = SMTP_AUTH; // Enable TLS encryption, `ssl` also accepted
$mail->Port = SMTP_PORT; // TCP port to connect to
//Recipients
$mail->setFrom($this->fromEmail, $this->fromEmailName); // Add a FROM
$addresses = explode(',', $recipient);
foreach ($addresses as $address) {
$mail->AddAddress(trim($address)); // Add a recipient(s)
}
if ( !empty($this->emailCC) ) $mail->addCC($this->emailCC); // Add a CC
//13-03-2019: Add the attachment to the email
$mail->AddStringAttachment($attachment, $filename, $encoding, $contentType);
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = 'This email is formatted in HTML';
$mail->send();
$this->fo->printStatus('Email successfully sent to: '. $recipient );
return true;
} catch (Exception $e) {
$this->fo->printStatus( basename(__FILE__) .' '. __LINE__ . ': Message could not be sent. Mailer Error: '. $mail->ErrorInfo );
return false;
}
The email gets delivered to me BUT ...
Problems:
When viewing in Gmail browser - I get message: "
Gmail virus scanners are temporarily unavailable – The attached files haven't been scanned for viruses. Download these files at your own risk."
When viewing in Gmail browser - I cant save/download the file? (clicking the download button does nothing)
When clicking attachment to view in browser, I now get error: "Whoops. There was a problem while previewing this document"
I try "Show Original" and it takes 30+ seconds for the email to load which just shows the base64 encoded data
I tried to open in inbox in Outlook and after 5 minutes of the emails not loading I gave up (thinking the emails are not encoded properly or something causing outlook to get stuck)
It looks like it is working (i.e. the file looks legit based on the gmail icon preview) but I cant do anything else with it and I don't know if it is a Gmail issue or File Issue.
Any advice?
Turns out that Gmail was having issues all yesterday afternoon with attachments. It was a Gmail issue - The timing is unbelievable
https://www.theguardian.com/technology/2019/mar/13/googles-gmail-and-drive-suffer-global-outages

Wamp Server and PHP mailer

I have a WAMP server database which contains users with their emails and activation codes.
How do I send an email for every new record in the WAMP server database automatically with its activation code? Using PHP.
P.s: I can already send an email from WAMP using PHP mailer but I have to specify the receiver each time.
This is the mail.php script that I use for sending emails using PHP mailer
<?php
require "init.php";
require"PHPMailerAutoload.php";
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Mailer = "smtp";
$mail->Host = "smtp.gmail.com";
$mail->Port = "587";
$mail->IsHTML(true);
$mail->Username = "******#gmail.com";
$mail->Password = "******";
$mail->From = "*******#gmail.com";
$mail->FromName = "Vodafone-El7a2ny";
$mail->AddAddress("*****", "Marwa Hashem");
$mail->Subject = "Activation Code";
$mail->Body = " Dear User,
Thank you for registering in El72any Mobile Application,
Your Activation Code is
Best Regards,
****";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Email was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
exit;
} else {
echo 'Email has been sent.';
}
?>
This is the register.php script
<?php
require "init.php";
$EmailAddress=$_POST["EmailAddress"];
$MobileNumber=$_POST["MobileNumber"];
$Password=$_POST["Password"];
$sql_query = "insert into user_information VALUES('$EmailAddress', '$MobileNumber', '$Password','');";
if(mysqli_query($con,$sql_query))
{
echo "<h3>Database Insertion Success...</h3>";
}
else
{
echo "Data Inerstion Error...".mysqli_error($con);
}
?>
Also this is the init.php script I used to connect to my database
<?php
$db_name="CustomerDB";
$mysql_user="root";
$mysql_pass=null;
$server_name="localhost";
$con=mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);
if(!$con)
{
echo "Connection Error...".mysqli_connect_error();
}
else
{
echo "<h3>Database connection Success...</h3>";
}
?>
This is really an opinion question since you've not posted any code. It helps to start by reading the docs and examples that are provided with PHPMailer. In your case, start with the mailing list example.

Awardspace Email Setting

I got a Award Space Mail Hosting account.I created that account only for the free email sending feature.
Tried
PHP mailer
swiftmailer ect..
But no use.Can anyone give me a full working code of php and mail form,so that i can just test it in my server .I cound send emails when using this file :
http://www.html-form-guide.com/php-form/php-form-validation.html
But,i dont want that peace of code.I want a perfect code that can work on My server.
Sample code:(Has an html form submit form)
<?php
if(isset($_POST['submit'])) {
$myemail = “support#domain.dx.am”;
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = “From:Contact Form <$myemail>\r\n”;
$headers .= “Reply-To: $name <$email>\r\n”;
echo “Your message has been sent successfully!”;
mail($myemail, $subject, $message, $headers);
} else {
echo “An error occurred during the submission of your message”;
}
?>
Or i tried doing the same with php mailer:
<?php
require 'filefolder/mailer/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'support#whatever.dx.am'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->From = 'support#whatever.dx.am';
$mail->FromName = 'Support';
$mail->AddAddress('anything#gmail.com'… // Name is optional
$mail->WordWrap = 50; // Set word wrap to 50 characters
$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;
exit;
}
echo 'Message has been sent';
?>
I am doing something wrong. But cant figure out what. Can anyone help me out .
The 'from' header should be an existing email account inside your Email Manager of your Hosting Control Panel.
as their FAQ says:
Tip: Please note that the 'From' header should be an existing email account inside your Email Manager of your Hosting Control Panel.
FAQ

cannot have a variable as phpmailer to address

I'm trying to use phpmailer to send emails to addresses stored in the variable $to like this
$mail->AddAddress($to);
but I keep getting an error message saying this
You must provide at least one recipient email address.
I have tried printing $to and it prints out the correct email address where I want the message to be sent. The mail gets sent if I put in an email address (e.g. test1#gmail.com) instead of $to. Could anyone help? Thanks!
This is the context:
// if the email seller form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// retreive the seller's email using his id
$seller_id = $_GET["sellerid"];
// query for the seller's email
$user_query = query("SELECT username FROM users WHERE id = ?", $seller_id);
$to = $user_query[0]["username"];
// send an email to the seller
require_once("PHPMailer/class.phpmailer.php");
// instantiate mailer
$mail = new PHPMailer();
// use your ISP's SMTP server
$mail->IsSMTP();
$mail->Host = "smtp.fas.harvard.edu";
// set From:
$mail->SetFrom($_POST['buyer_email']);
// set To:
$mail->AddAddress($to);
// set Subject:
$mail->Subject = $_POST['subject'];
// set body
$mail->Body = $_POST['message'];
// set alternative body, in case user's mail client doesn't support HTML
$mail->AltBody = "Please view this message in an HTML-enabled browser.";
// send mail
if ($mail->Send() === false)
die($mail->ErrorInfo . "\n");
This is the query function
/**
* Executes SQL statement, possibly with parameters, returning
* an array of all rows in result set or false on (non-fatal) error.
*/
function query(/* $sql [, ... ] */)
{
// SQL statement
$sql = func_get_arg(0);
// parameters, if any
$parameters = array_slice(func_get_args(), 1);
// try to connect to database
static $handle;
if (!isset($handle))
{
try
{
// connect to database
$handle = new PDO("mysql:dbname=" . DATABASE . ";host=" . SERVER, USERNAME, PASSWORD);
// ensure that PDO::prepare returns false when passed invalid SQL
$handle->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch (Exception $e)
{
// trigger (big, orange) error
trigger_error($e->getMessage(), E_USER_ERROR);
exit;
}
}
// prepare SQL statement
$statement = $handle->prepare($sql);
if ($statement === false)
{
// trigger (big, orange) error
trigger_error($handle->errorInfo()[2], E_USER_ERROR);
exit;
}
// execute SQL statement
$results = $statement->execute($parameters);
// return result set's rows, if any
if ($results !== false)
{
return $statement->fetchAll(PDO::FETCH_ASSOC);
}
else
{
return false;
}
}
Your problem is...
// if the email seller form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") //<-- POST HERE
{
// retreive the seller's email using his id
$seller_id = $_GET["sellerid"]; //<-- GET HERE

Resources