PHPMailer goes to spam - phpmailer

I have problem with PHPMailer. Messages go to spam on o2 and Hotmail. On other servers it works well. Here is my code:
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$mail = new PHPMailer();
$mail->From = "abc#mydomain.pl";
$mail->FromName = "XYZ";
$mail->AddReplyTo('abc#mydomain.pl', 'XYZ');
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.mydomain.pl";
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Username = "abc#mydomain.pl";
$mail->Password = "password";
$mail->Port = 25;
$mail->Subject = "Subject";
$mail->Body = "Message";
$mail->AddAddress ('xxx#yyy.pl','User');
$mail->Send();
Can anyone help?

Apart from the possibility that your server may be blacklisted for some reason, the most common cause for emails landing in spam servers that i encountered is that the from-address and the server's name do not match.
Consider a from-address like someone#mydomain.com sent from a server cheapwebhosting.com, the recipient mail server sees the discrepancy and will most likely consider this a spam message.
So, you should check the message headers of a test email if something like this is happening here (or if you notice anything else that looks fishy)

Related

phpmailer send mails via OWN mailserver, missing DKIM

i'm using phpmailer V 6.6.0
Here at stackoverflow are a lot of hints and tricks, how to create and use key files for sending DKIM-signed mails.
But my problem is very simple.
I can't remember to provide Thunderbird / Livemail / Outlook whatever with a .key-file.
All i want to do is to use phpmailer sending a mail via my mail server. Like all other EMail-Programs do.
This is my code so far:
$Server = "xxxxxx.xxxxxx.com" ;
$Username = "mxxxxx" ;
$Password = "xxxxxxxxxxxx" ;
$mail = new PHPMailer();
$mail->isSendmail();
// Define the sender
$mail->Host = $Server;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = $Username;
$mail->Password = $Password;
$mail->Hostname = "#thisdomain.com";
$mail->MessageID = "<".time()."#thisdomain.com>";
$mail->XMailer="MyMailer";
//Set who the message is to be sent from
$mail->setFrom($dbset['Sender']);
$mail->addReplyTo($dbset['Sender']);
$mail->addAddress($dbset['Receiver']);
$mail->Subject = "JUST A TEST";
$mail->isHTML(false);
$mail->Body = "This is just a test";
//send the message, check for errors
$Res = $mail->send();
if (!$Res) die('VERY BAD - Error sending mail!');
$mail->__destruct();
unset($mail);
Well it works great, beside of the "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
s=badeba3b8450; t=1652648844;
bh=x8/D1v6jj+heUcnMHbgz3HeVzmgGNIkhaOk...lots of bytes here..."
What am i doing wrong?
I don't need to set up an own mail server.
My mail server at my provider works great, including the DKIM signature.
Why won't it work with phpmailer?
Signing the Email is not the job of the client, it should be done at the mail server.
Or i'm wrong at this?
Helpless
Mac

phpmailer reply-to not working when reply from mobile app

I'm using phpmailer on my ERP and the from email is a noreply# and the reply-to is my client/company email.
Everything is working, however, I noticed that when a person is replying by a mobile app the reply goes to the "from" email and not the reply-to, also, that happens to the autoresponse.
How can I solve the problem?
This is part of the code
$mail->setFrom($from, $name_from);
$mail->addAddress(getToEmail($iduser));
$mail->ClearReplyTos();
$mail->addReplyTo($reply, "Reply to " . $name_from);
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Sender = $reply;
$mail->Subject = $subject;
$mail->Body = $message;
one more thing, I was told that mobile clients not always download the entire email but show a button to do so. These clients cannot see "reply-to" if the mail is not fully downloaded.
I am not sure if this is fully true ...

setFrom alternative goDaddy

I understand that gmail, yahoo, hotmail etc. etc. won't work with goDaddy and PHPMailer but what email address should I use for setFrom? I would appreciate any help in figuring this out! (I'm trying to have the name and email entered on an html contact form be emailed to me)
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->Host = 'localhost';
$mail->SMTPAuth = false;
$mail->SMTPAutoTLS = false;
$mail->Port = 25;
//Set who the message is to be sent from
$mail->setFrom('MY_UNUSABLE_EMAIL', 'MY_NAME');
//Set an alternative reply-to address
$mail->addReplyTo($_POST['email'], $_POST['name']);
//Set who the message is to be sent to
$mail->addAddress('MY_UNUSABLE_EMAIL', 'MY_NAME');
// Content
$mail->Body = <<<EOT
You've recieved a new submission from: {$_POST['name']}.
Their email is: {$_POST['email']}.
EOT;
$mail->Send();
?>

PHPMailer - multiple emails in same Page

My PHPMailer is working perfectly but my problem is that when i receive the different emails from different person´s , all the emails will be received inside the same message (because PHPMailer send emails always from 1 single email (management#gmail.com)).
Its possible to receive always emails in different messages?? Because like that its confused to manage the email.
IMAGEM_EMAIL
email2
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'management#gmail.com';
$mail->Password = '*********';
$mail->SMTPSecure = 'tls';
$mail->From = $_POST["email"];
$mail->FromName = $_POST["name"];
$mail->addAddress('website#gmail.com');
$mail->AddCC($_POST["email"], $_POST["name"]);
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $_POST["subject"];
There is two issues here:
1/ Your gmail/inbox is grouping the mails you receive from PHPMailer. And for that, there is no solution. It's what gmail/inbox do and you can't do anything about that.
2/ You want to hit "reply" to these mails and reply not to "management#gmail.com" but to your user's mail. You can add a "Reply-To" field in mails to achieve that:
$mail->addReplyTo($_POST["email"], $_POST["name"]);

My PHPMailer does not send "any" mail

I've been here since 9:15 AM DETERMINED to find others with the same problem I have. 95% of these PHPMailer look a lot like mine. The main difference is "MINE DOES NOT WORK!!" Please guys, take a "close"look at what I have and tell me where did I go wrong. (My coding below):
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer();
$mail->HOST = "smtp.gmail.com";
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Username = "johnm010247#gmail.com";
$mail->Password = "xxxxxxxxxxxxxxxxxx";
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Subject = "Test Email";
$mail->Body = "This Is Our Body.....";
$mail->setFrom("johnm010247#gmail.com", "Robert");
$mail->addAddress("mothers#bcbc-church.org", "Mothers Board");
if ($mail->send())
echo "Mail sent";
?>
I'm using PHPMailer 6.0
PHP is case sensitive for property and variable names.
$mail->HOST = "smtp.gmail.com";
Should be
$mail->Host = "smtp.gmail.com";
It would help if you based your code on the examples provided, since they do not contain basic errors like this.
Aside from that, when posting a question, you need to specify what the problem is; “it doesn’t work” is not enough.

Resources