PHPmailer sending 3 times Email with 1 attachment - php

i got a problem and i cant find any solution.
When customers shop with me on the site, they come to a thank you page. Since we send with phpmailer an email with attachment invoice. The email is however unfortunately sent 3 times and only once with attachment and the correct parameter. The other two mails are naked without price without address without name without attachment.
PHPmail code:
<?php
require_once (JPATH_ROOT.'/PHPMailer/class.phpmailer.php');
require_once (JPATH_ROOT.'/PHPMailer/language/phpmailer.lang-de.php');
$mail = new PHPMailer;
$mail->From = 'info#picknstick.de';
$mail->FromName = 'pickNstick';
$mail->addAddress($arr["email"]);
$mail->addReplyTo('info#picknstick.de');
$mail->addCC('info#picknstick.de');
$mail->isHTML(true); // Mail als HTML versenden
$mail->Subject = 'pickNstick-Rechnung';
$mail->AddAttachment($_SERVER["DOCUMENT_ROOT"].'rechnung/'.$pdfName, 'Rechnung_pickNstick.pdf');
$mail->Body =
'
Hallo <b>'.$arr["nachname"].' '.$arr["name"].'</b>,
<hr>
';
if(!$mail->send()) {
echo 'Mail wurde nicht abgesendet';
echo 'Fehlermeldung: ' . $mail->ErrorInfo;
} else {
echo 'Rechnung wurder per Email nochmals an Sie verschickt !';
}
?>
I think my Code works and there is nothing wrong...
Why is Joomla sending this mail 3 Times ?
www.picknstick.de <--- Online - Shop
How/Where can i search for this Problem ?

Related

Only receive emails from gmail when users submit my forms and not yahoo or icloud using phpmailer [duplicate]

This question already has answers here:
How do you make sure email you send programmatically is not automatically marked as spam?
(24 answers)
Closed 4 years ago.
I have a simple website set up on godaddy, decided to add emails straight to me instead of through godaddy, started using the phpmailer and I only receive emails from users submitting on my website form if they send an email with gmail. All other emails get ignored. Wonder if it's a godaddy issue.
$connect = mysqli_connect('localhost', 'pf', '*********', 'bs-portf');
if(mysqli_connect_errno()){
echo "Failed to connect" . mysqli_connect_error();
}
if(mysqli_ping($connect)){
// echo "we are connected";
}else{
echo "Error: ". mysqli_error($connect);
die("Connection failed");
}
?>
<?php
if(isset($_POST['submit'])){
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPmailer();
$name = $_POST['name'];
$email = $_POST['email'];
$message = nl2br($_POST['message']); //nl2br() new lines in text message to break tags
$mail->Host='smtp.gmail.com';
// $mail->isSMTP();
$mail->Port=465;
$mail->SMTPAuth=true;
$mail->SMTPsecure='ssl';
$mail->Username='bradv#gmail.com';
$mail->Password='**********';
$mail->setFrom($email, $name);
$mail->addAddress('bradv#gmail.com');
$mail->addReplyTo('info#example.com', 'Information');
$mail->isHTML(true);
$mail->Subject='Form Submission';
$mail->Body= "test email body 1";
// $mail->Body='<p align=center>Name :'.$name. '<br>Email: '.$email.
'<br>Message '.$message. '</p>';
// echo "submit worked";
if($mail->send()){
echo 'mail is sent';
// $result ="Something went wrong. Please try again.";
}else{
echo 'email failed';
// $result="Thanks " .$name. " for contacting us. We'll get back to you
soon!";
}
Check the spam folder. If you send an email using one address as login but sets the From address as another, Gmail will think its spam.
Set from address with the same email as the login and replyto as the user's email.

phpmailer not sending email to gmail,yahoo,hotmail or these are blocking email sent by phpmailer

i am using PHPmailer to send emails
here is code that i have used:
$mail = new PHPMailer();
$subject = "test";
$to = "test_patel#yahoo.com"
$mail->SetFrom("PDSociety#aol.com","Punjab Dental Society");
$mail->AddReplyTo("PDSociety#aol.com", "Punjab Dental Society");
$mail->Subject = $subject;
$mail->MsgHTML($str);
$mail->AddAddress($to, "Punjab Dental Society");
if(!$mail->Send())
{
$err = "Mailer Error: " . $mail->ErrorInfo;
//echo $err;
} else {
$msg = "Message sent!";
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
if i change email address from yahoo to gmail or hotmail, still email are not sent.
i checked by echoing error, but no errors.
can anyone explain what is the issue ?
After trying various ways, i found following code working with almost all email providers
$to['email'] = "recipients email address";
$to['name'] = "name";
$subject = "email subject";
$str = "<p>Hello, World</p>";
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'Specify main and backup server here';
$mail->Port = 465;
$mail->Username = 'xyz#domainname.com';
$mail->Password = 'email account password';
$mail->SMTPSecure = 'ssl';
$mail->From = 'From Email Address';
$mail->FromName = "Any Name";
$mail->AddReplyTo('xyz#domainname.com', 'any name');
$mail->AddAddress($to['email'],$to['name']);
$mail->Priority = 1;
$mail->AddCustomHeader("X-MSMail-Priority: High");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $str;
if(!$mail->Send()) {
$err = 'Message could not be sent.';
$err .= 'Mailer Error: ' . $mail->ErrorInfo;
}
$mail->ClearAddresses();
variable values needs to be changed accordingly.
Hope these helps people having issues with PHPmailer
PHPMailer is only involved in submitting the message to your own mail server, and you're not having any problem there. After that, your mail server takes on the responsibility of sending it on, so you will find the answer in your mail server's logs.
There is no simple way to ensure messages end up in the inbox and not spam - if there was, spammers would be using it and filtering would be useless. Make sure your DNS resolves backwards and forwards, that you have valid SPF records, that you sign your messages with DKIM (especially important for Yahoo) and most importantly, that you don't send messages that your recipients think are spam.
Try this :
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->AddAddress($to['email'],$to['name']);
$mail->FromName = '';
$mail->Subject = $subject;
$mail->MsgHTML($message);
$send = true;
return $mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$e->getMessage(); //Boring error messages from anything else!
}
It will help you if any exception error.
Have you looked on the post here: Using PHPMailer Results in many blocked emails? The asker solved the issue by changing the email subject:
Well I solved the issue; the code above was not the problem and works
great.
In my subject, I used a phrase regarding "verify your account
information" and that got it blocked on a few ISP's.
So the lesson is, your subject matters. I was looking at my php code
and my body content before I realized this.
The content of the email and its subject can make ISPs ban it. You could try taking the content of one of your received emails from your inbox and see if that goes through.

PhpMailer sends to gmail but not to hotmail accounts

I know this has been asked before, but i wanted to show my case because i tried to solve it with other answers but i coundt solve it.
I m trying to do a Contact form but when i choose the email of the receiver if i choose #hotmail.com or #advancedinstitute.cl they dont receive the email.
I tried to choose another type of email like gmail, yahoo or terra and the email arrives without problem.
I know it must be because the spam policies of those servers but i dont know how to fix it.
This is my code of the phpMailer:
$mail = new PHPMailer();
$mail->Host = "localhost";
$mail->Hostname = "Advanced Institute";
$mail->From = $_POST["email"];
$mail->FromName = $_POST["email"];
$mail->Subject = "Quiero contactarme con Advanced Institute";
$mail->AddAddress("carmeng.advanced#terra.cl","Advanced Institute");
$mail->AddReplyTo($_POST["email"]);
$mail->IsHTML(true); // El correo se envĂ­a como HTML
$body = '<html><body><div>Nombre : '.$_POST["nombre"].'<br> Email : '.$_POST["email"].'<br> Telefono : '.$_POST["telefono"].'<br> Asunto : '.$_POST["asunto"].'<br> Comentarios: '.$_POST["comentarios"].'<br> </div></body></html>';
$mail->Body = $body;
if(!$mail->Body) {
echo 'Error: ' . $mail->ErrorInfo;
}else{
$mail->Send();
I hope my english was enough for you guys to understand my problem.
THANK YOU IN ADVANCED
You probably need to set up SPF records for the domain name.
Further information: http://en.wikipedia.org/wiki/Sender_Policy_Framework
Recommended SPF Wizard http://www.kitterman.com/spf/validate.html
Also the from address should be from the sending domain name, not user input.

PHP mail is not sending, but result is true

i use phpmailer for sending emails. in one script, the code works fine, in other exaple, result is true, but no mail is delivered. error log is empty, what would you recommend to check?
thanks
include_once '/var/www/xxxxxx.cz/web/php/phpmailer.php';
$to = 'dubcznic#gmail.com';
$to_name = '';
$from = 'robot#xxxxxx.cz';
$from_name = 'Robot';
$mail = new phpmailer();
$mail->CharSet = 'UTF-8';
$mail->From = $from;
$mail->FromName = $from_name;
$mail->AddAddress($to, $to_name); // Add a recipient
$mail->AddCC('nabytek-safr#xxxx.cz');
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Import Robot Autronic';
$mail->Body = 'xxx';
$mail->AltBody = str_replace("<br />", "\n", 'xxx');
if (!$mail->Send())
{
echo 'Mail Error: ' . $mail->ErrorInfo;
exit;
}
else
{
echo 'OK';
}
die();
Check what text you are sending. It could be that your results are being filtered out and put in a Spam folder. Sometimes a mail with 'test' in the title could be sent right to Spam.
It is impossible to verify that an email was delivered with PHP.
Check your mail server log (usually /var/log/mail) to see if the email was sent.
Send a BCC to an email address that you know has no spam filters.
You can validate real emails with Telnet and MX records. See this answers
https://stackoverflow.com/a/17332773/468891
First, check your spam, if you haven't already.
Second, change your SMTP settings to that of gmails, put your gmail log in and password and try.
If a mail fails to deliver you'll get an delivery- failure notification with possible causes of failure, which helps a lot. A delivery failure can also happen when no error is displayed in PHP.
This always helps me.

PHPMailer With Attachment Never Received

I am tying to send an email with an attachment using phpmailer.
include_once('/home/site/PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.free.fr"; // SMTP server
$mail->IsSendmail(); // telling the class to use SendMail transport
$mail->From = "name#sub.fr";
$mail->FromName = "name";
$mail->Subject = "subject";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("sub#sub.net", "name");
$mail->AddAttachment("mylist.csv"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I receive a "Message sent !" on execution, but no email is ever received.
It is very possible the user you sent the email to did not recieve it due to the fact a lot of mail providers such as AOL and Yahoo block massive amounts of Ip addresses related to email spam. So if the server you are running this php script from is on their blacklist the user will not even receive it to the spam folder.
Check your php email logs.
http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-03.html
Also, if this is not the case, try making sure the file your trying to include exists, and you are passing the correct path to the file. Like #Waygood said, try seeing if it sends without the attachment.

Categories