Setting SMTP in php.ini to make mail() function work

I’ve never used it either, but it was a recommendation on GoDaddy’s help area.

https://www.godaddy.com/community/Managing-Email/PHPMailer-smtp-error-connection-refused/m-p/70120#M6826

thanks for sticking with me guys. I’ve got an on site to do. I’ll be back with you in about 1-2 hours. I’ll review everything uve posted when i get back. by the way Ernie, the name is ADAM, not vba_php. :slight_smile:

Welcome to the organized chaos Adam

Like the “organized chaos” ! ! !

Thanks Adam… Figured you would tell us your name eventually…

Astone, I have both a Linus and a Cpanel Godaddy access. Both do not have Mx-Entry in it.
For some reason, I can not see ANY of the MX records in my hosting. Must have something to do with
Godaddy’s set up. I remember a long time ago, I had access to it under the domain-name area, but,
can not find it on either access panels now. Hmmmmm…

I don’t use shared hosting, so I can’t help with what I have! I also haven’t had GoDaddy since they got huge and the service went down.

I here you one that! They are now more of a marketing system not a server system… LOL

Ernie,

what should I ask godaddy to help with? they do not offer PHP help. that’s not their business, as they say every damn time. take a look at the text file in the link below. that’s the entire code I’m running, which I got from you. I’ve been doing so much crap today that it’s very possible I’ve missed something small that another set of eyes might be able to spot. File:

https://drive.google.com/file/d/15pjcCyZQLFrX_LdAg3qnw_bFwzdEMrwR/view?usp=sharing

by the way you guys, godaddy sucks terribly! and has for a long time ago. When Parsons was running the place it was great, but then the imitators came in with all their hot air and totally destroyed a good thing. Just like when MS was great back in the day when Gates was writing all the code. Now it’s run by corporate hot heads like Ballmer (he’s gone though. maybe Ballmer was OK, but ever since Gates stopped running day to day, it’s not the same).

Ernie,

Teir 1 support at godaddy doesn’t know shit, so I’m waiting on tier 2 right now. but these 2 lines is what I mentioned to the agent on tier 1:

$mail->isSMTP();
$mail->SMTPAuth = false;

and he didn’t know what those meant, but he did say that none of godaddy’s servers allow mail to go through if it’s not authorized. he also says that people who have mail systems (plugins) installed on their wordpress sites often run into the server declining the send operation too. so I’ll update this when I talk to the tier 2 joker.

Well, I noticed you did not use the server’s email in the reply-to. You used an outside server, Gmail, there.
Try it with that being the same as your FROM address…

They would not know what those two OBJECT lines are. $mail-> is an object. In this case the PHPMailer
object which is nothing to do with Godaddy. But, the words: SMTP Authentication = false might be usefull.
Wording it everything when it comes to a server company like Godaddy. And, yes, the Tier2 tech will be
much more helpful… They know their stuff much better than the general phone answer tier 1 people.
I am leaving for the night in about an hour. And, be back around midnight EST… Just FYI…

Adam, also, why do you keep posting images of your code?
Just copy and paste them here and then tag them with the quotes or pre-formatted tags.
Then, we see what you see without going thru the image junk… Just a thought!

i made the change Earnie, and I still get the same damn thing: We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. I talked to godaddy, they ran a test script and everything checked out. the tier 1 agent told me that tier 2 won’t let him transfer me cuz there is not enuf evidence to support a case. so they shut me out completely. and since their test script was successful, they insist that it’s our fault and they cannot do anything else to help. one other thing…they said their servers do not allow 3rd party SMTP to go through. is that the problem? considering that there are SMTP properties/attributes being assigned to the $mail object instance in this code of ours?

If there is nothing else that can be done then I might switch the god damn hosting company cuz I told them I would believe you over them anyday. These guys have always sucked and have always been ignorant about complex issues i’ve called in with. so this isn’t the first time that frustration has resulted from a phone call with these idiots.

I have SMTP working on other Godaddy servers. So, my guess is that it is just the authentication issues.
Leaving now for several hours. I will PM you when I get back. I feel there are some things we can do,
but will discuss it when I get home. You are a few hours off my EST, so maybe you will still be up.
Gotta rush off for a Texas Holdem Holiday bash… Later! Take a deep breath and put this on hold for a bit.
More later…

I love poker, but I rarely play and never for money. I did that in college and I was the dealer. usually the dealer makes the money, but in my case I lost my ass in that sitting! I was dealing to 6 players for 6 hours straight. and I’m on PST, not EST, so I’m only 1 hour behind you. I will definitely be up when you get home. I hope we can get this done before turkey day tomorrow!

Well, the guys played extremely late and I have been a bit busy today. Have a great Thanksgiving day and dinner! I will check in later on. But, my thought was to have you give me access to your server so I can directly run some tests and see how your mail server is set up. I do not understand why it fails on yours and several Godaddy servers that I have similar code on works just fine. I did look at one and that one I had set up SwiftMail as it seemed to work well for them. That was the one in Australia.

It you want to do that, private message me and we can discuss it further. Planning on watching some football today. I run a football pool on one Godaddy server. It uses standard PHP Mail() functions and does not use SMTP. This also works very well for this site. We could just use regular mail() functions if you wish. Either way is good for me…

I sent you a PM. and no, using mail() is what started this thread to begin with. remember? it is getting spammed out by gmail. that’s why we’re implementing this. if i had to go back to using maik(), that would mean we’ve wasted 3 whole days with this stuff.

ok ernie, here is the code I ran in the test.php file:

<?php

error_reporting(E_ALL); // TEMP ! ! ! ! ! ! ! ! ! ! !
ini_set(“display_errors”, 1); // TEMP ! ! ! ! ! ! ! ! ! ! !

// Import PHPMailer classes into the global namespace
ini_set(‘include_path’, ‘PHPMailer’);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require “…/PHPMailer/src/PHPMailer.php”;
require “…/PHPMailer/src/SMTP.php”;
require “…/PHPMailer/src/Exception.php”;

//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(“America/New_York”);

//Create a new PHPMailer instance
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom(“[email protected]”, “Business Name Corporate”);
//Set an alternative reply-to address
$mail->addReplyTo(“[email protected]”, “Business Name Corporate”);
//Set who the message is to be sent to
$mail->addAddress(“[email protected]”, “Adam Evanovich”);
//Set the subject line
$mail->Subject = “PHPMailer sendmail 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”), DIR);
//Replace the plain text body with one created manually
$mail->AltBody = “This is a plain-text message body”;
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: ". $mail->ErrorInfo;
} else {
echo “Message sent!”;
}
?>

and it worked just fine. i put the HTML markup test in a separate file called contents.html and put it in the /php directory, cuz obviously the code is pointing to it. I got the following message on “test.php” after running the script:

Notice: Use of undefined constant DIR - assumed 'DIR' in /home/ownersName/public_html/DOMAIN/php/test.php on line 36
Message sent!

so what is the argument DIR?? am I spose to include the absolute path of “contents.html” in there? or just surround it in quotes? that’s what it seems like the message is saying…the message did indeed appear in gmail’s inbox and was not spammed out. so why exactly did this one work!? I’m a little stumped in that regard. here is an image of what I saw in gmail’s inbox:

What do you mean by "It is getting SPAMMED out by gmail???
Do you mean it is going into your spam filter? That happens with a lot of emails if the email looks like spam.
You just need to mark it as NOT spam. So does that mean it is actually sending out mail and then your
email client, Gmail, is doing something wrong? That would mean it is nothing to do with your server, but,
a problem with Gmail which can be fixed by just putting your server on the Gmail Whitelist…

I would do the HTML template part like this:

$template = file_get_contents(“contents.html”);
$mail->msgHTML($template);

The “DIR” part is supposed to have a couple underlines before and after it to point at the current dir.
like __DIR__ But, it is NOT even needed.

Ernie, you just said:

What do you mean by "It is getting SPAMMED out by gmail???
Do you mean it is going into your spam filter? That happens with a lot of emails if the email looks like spam.

based on what i’ve just quoted you, your words from your last post, ur telling me that I once again said gmail was sending the message to the spam folder. NO it isn’t! it worked! my question was: why did your latest code snippet get thru to gmail’s inbox when all your previous scripts did not? is it because we are including the HTML content in a separate HTML file and pointing to it with the PHP code?

No, the old code was for SMTP. This version is NOT. This version is the plain type of emails.
I highly doubt it was “spammed out”. Most likely the other code just was not sending the email out.

But, it appears this version is working for you. Nice!

Sponsor our Newsletter | Privacy Policy | Terms of Service