I want to send email to two users when the count is not zero. When I am making
$semail = $row_seller['seller_email']; its working but when I make it
$semail = $row_seller['seller_email'].",example#gmail.com"; its not, I want to send it to both. How can i do it.
<?php
$query1 = "select * from `seller` where seller_pincode = $pincode";
$run_query1 = mysqli_query($con, $query1);
$count_seller = mysqli_num_rows($run_query1);
if ($count_seller == 0)
{
$semail = "example#gmail.com";
$sname = $saddress = $spincode = $scity = $sstate = $sphone = $sgst = $span = "Not Available";
}
else
{
while ($row_seller = mysqli_fetch_array($run_query1))
{
$semail = $row_seller['seller_email'] . ",example#gmail.com";
}
}
$email = $semail;
$subject = "Order Details";
$message = 'You got a new Order!!! ";
require_once('mailer / class . phpmailer . php);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
You need to use addAddress method or addCC for add copy, like so
$mail->addAddress('mail#domain.com', 'NAME'); //add address
$mail->addCC('mail#domain.com', 'NAME'); / add copy
Github
Related
I am using PHPMailer to send mails with Google_Service_Gmail,but mails are not getting delivered although status is showing SENT.I have created a valid OAth Credentails for Gmail api,which did deliver 5 mails,but then stopped sending mails,although status is showing as SENT
Using Google_Service_Gmail with PHPMailer
try {
$mail = new PHPMailer();
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->CharSet = "UTF-8";
$mail->From = $sender;
$mail->FromName = $alias;
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $messageText;
$mail->IsHTML(true);
$mail->preSend();
$mime = $mail->getSentMIMEMessage();
$mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
// $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$message = new Google_Service_Gmail_Message();
$message->setRaw($mime);
$client = getClient();
$service = new Google_Service_Gmail($client);
$message = $service->users_messages->send($sender, $message);
if ($message->labelIds[0] == "SENT") echo 'Message with ID: ' .$message->getId()."-".$message->labelIds[0];
else echo "Something went wrong...";
return $message;
} catch (Exception $e) {
print "Error" . $e->getMessage();
}
// return null;
}
Returns
Message with ID: 1845b21052f00d8e-SENT
but the e-mail is not delivered.
Right now I am doing a system. This system will send notification if educators have update a quiz. I want to send email to multiple user. I have refer this question 17860172 and Its solution but Its not works.
This is my code:
$result = mysql_query("SELECT * FROM student WHERE className='$classname'");
while ($rec= mysql_fetch_array($result))
{
$title = "Quiz Information";
$body = "Your quiz have been updated";
$email = $rec['stuEmail'];
}
include_once("mailer/mailer.php");
okey, for the mailer.php :
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "***";
$mail->Password = "***";
$mail->From = "iii#gmail.com";
$mail->FromName = "i System";
$mail->AddAddress($email);
$mail->Subject = $title;
$mail->MsgHTML($body);
if (file_exists($path)){
$mail->AddAttachment($path);
}
$mail->WordWrap = 50;
$mail->Send();
I want to send to all email in database based on className but when I click submit button the email doesn't send at all.
You can try this :
$result = mysql_query("SELECT * FROM student WHERE className='$classname'");
while ($rec= mysql_fetch_array($result))
{
$title = "Quiz Information";
$body = "Your quiz have been updated";
$email = $rec['stuEmail'];
mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "***";
$mail->Password = "***";
$mail->From = "iii#gmail.com";
$mail->FromName = "i System";
$mail->AddAddress($email);
$mail->Subject = $title;
$mail->MsgHTML($body);
if (file_exists($path)){
$mail->AddAttachment($path);
}
$mail->WordWrap = 50;
$mail->Send();
}
When I am getting envelope by RequestStatus all recipients have same routing number. But I am sure and debug that provided different parameter for each recipient. And all recipients gets email in same time. How can I send envelope for each recipient according to RoutingOrder?
Sequential Signing (API) enabled for my account:
My examlple:
WebAPI.Recipient[] recipients = {new WebAPI.Recipient(), new WebAPI.Recipient()};
recipients[0].Email = "JohnDo#gmail.com";
recipients[0].UserName = "John Do";
recipients[0].Type = WebAPI.RecipientTypeCode.Signer;
recipients[0].ID = "2";
recipients[0].RoutingOrder = 2;
recipients[1].Email = "JohnDo2#gmail.com";
recipients[1].UserName = "John Do2";
recipients[1].Type = WebAPI.RecipientTypeCode.Signer;
recipients[1].ID = "1";
recipients[1].RoutingOrder = 1;
// Create envelope
WebAPI.Envelope envelope = new WebAPI.Envelope();
envelope.Subject = "Subject line mandatory!";
envelope.Recipients = recipients;
envelope.AccountId = APIAccountId;
// Create document
envelope.Documents = new WebAPI.Document[1];
WebAPI.Document doc = new WebAPI.Document();
doc.ID = "1";
doc.Name = "Picture PDF";
doc.TransformPdfFields = true;
doc.PDFBytes = Properties.Resources.test;
envelope.Documents[0] = doc;
// Create tab
WebAPI.Tab tab = new WebAPI.Tab();
WebAPI.AnchorTab anchorTab = new WebAPI.AnchorTab();
anchorTab.AnchorTabString = "Adobe";
anchorTab.IgnoreIfNotPresent = true;
anchorTab.IgnoreIfNotPresentSpecified = true;
tab.AnchorTabItem = anchorTab;
tab.CustomTabRequired = false;
tab.SenderRequired = false;
tab.Type = WebAPI.TabTypeCode.SignHere;
tab.DocumentID = "1";
tab.RecipientID = "1";
WebAPI.Tab tab2 = new WebAPI.Tab();
WebAPI.AnchorTab anchorTab2 = new WebAPI.AnchorTab();
anchorTab2.AnchorTabString = "CustomTag";
anchorTab2.IgnoreIfNotPresent = true;
anchorTab2.IgnoreIfNotPresentSpecified = true;
tab2.AnchorTabItem = anchorTab2;
tab2.Type = WebAPI.TabTypeCode.SignHere;
tab2.DocumentID = "1";
tab2.RecipientID = "2";
tab2.SenderRequired = false;
tab2.SharedTab = true;
tab2.TabLabel = "CustomTag";
tab2.Value = "Value2";
envelope.Tabs = new WebAPI.Tab[2];
envelope.Tabs[0] = tab;
envelope.Tabs[1] = tab2;
// Get results
WebAPI.EnvelopeStatus status = apiClient.CreateAndSendEnvelope(envelope);
Request to DocuSing SOAP API:
Request to DocuSing SOAP API
Problem resolved by adding option: for RoutingOrderSpecified = true each recipient ;
This code resolve problem for me:
recipients[0].RoutingOrderSpecified = true;
recipients[1].RoutingOrderSpecified = true;
I've been googling and trying different solutions for hours.
It works fine with GMail and Yahoo, but with Hotmail, it goes to the junk folder.
This is my code:
$sender = "xxx";
$sendername = "xxx";
$recipient = "xxx";
$recipientname = "xxx;
$pm->SetFrom($sender, $sendername);
$pm->AddReplyTo($sender, $sendername);
$pm->Sender = "xxx";
$pm->AddAddress($recipient, $recipientname);
$pm->IsSMTP();
$pm->SMTPAuth = true;
$pm->SMTPDebug = 2;
$pm->Host = "mail.xxx.com";
$pm->Port = 587;
$pm->Username = "xxx";
$pm->Password = "xxx";
$pm->Subject = "xxx news";
$pm->AddEmbeddedImage('forumLogo.png', 'logo');
$pm->Body = 'Here is my HTML content, not spammy.
</body>
</html>';
$pm->isHTML(true);
var_dump($pm->ErrorInfo);
if(!$pm->Send()) {
echo "Couldn't send: " . $pm->ErrorInfo;
}
else {
echo "Sent";
}
This mailer works with go daddy but I cant get it too work with a home server. It will send the mail and shows up in the inbox but not the content. I think it has to do with using $body tag but I am not sure any suggestions?
<?php
// PHPmailer settings
$mail = new PHPMailer(); // create a new object
$mail->Issmtp(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "email"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From = $email;
$mail->FromName = $contact_name;
$mail->SetFrom($email, $contact_name);
$mail->AddAddress('email');
$mail->Priority = 1;
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Gray Gables maintenance request";
$mail->Body = $body;
$mail->AltBody = "This is the text-only body";
// gets info from form
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$message = $_POST['message'] ;
$ip = $_SERVER['REMOTE_ADDR'];
// defines how message looks in email
$mail->Body="
Name: $name<br>
Telephone: $phone<br>
Email: $email<br>
IP address: $ip <br>
-------------------<br>
Message:<br>
$message";
// looks good in your inbox
$mail->From = "$email";
$mail->FromName = "$name";
$mail->AddReplyTo("$email","$name");
// gives success or error
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo '
<meta http-equiv="refresh" content="3;url=http/">
<center><font size="5px">
Message has been sent!!<br>
you will be redirected to our home page in 3 seconds...<br>
click here to return now.
</font>
</center>
';
?>
<?php
echo ' Client IP: ';
if ( isset($_SERVER["REMOTE_ADDR"]) ) {
echo '' . $_SERVER["REMOTE_ADDR"] . ' ';
} else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) {
echo '' . $_SERVER["HTTP_X_FORWARDED_FOR"] . ' ';
} else if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) {
echo '' . $_SERVER["HTTP_CLIENT_IP"] . ' ';
}
?>
I think you are looking for this...
$body = file_get_contents('yourfile.html');
You can attach any HTML content in 'yourfile.html', which displays in your body of the mail.