Jump to content

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


ajetrumpet

Recommended Posts

ok guys,

another issue for me i cannot find an answer for.  according to this thread: https://stackoverflow.com/questions/8803994/php-mail-not-working-for-some-reason, mail() doesn't work when smtp is not configured properly.  I checked my server files and I do not have a .ini file.  am I spose to have one by default?  and, according to this question in the godaddy community: https://www.godaddy.com/community/Using-WordPress/PHP-ini-how-to-make-changes-using-cPanel/td-p/119704, configuration of PHP in general should be done in the .user.ini file instead of in php.ini.  the following code, which is what I have now, results in no mail being sent to my address so either my code is wrong or my configs are not set properly I'm guessing:

if( empty($errors))
{
    $to = '$myemail';
    $email_subject = "Demo Request Submitted";
    $email_body = "A demo request was submitted through your website with the following information:" .
    	"Contact Name: " . $contact . " </br>" . 
    	"Company: " . $company . " </br>" .
    	"Email: ". $email . " </br>" . 
    	"Phone: " . $phone . " </br>" . 
    	"Best Time to Contact: " . $best_time_to_contact . " </br>" . 
    	"Message: " . $message;
    $headers = "From: " . $myemail . "\n";
    $headers = "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n";
    mail($to, $email_subject, $email_body, $headers);

    echo "Your demo request has been sent.";
} else {
	echo $errors;
	   }

also, in the stackoverflow article I mentioned above, one of the responders suggests using PHPMailer as a better way to send mail using PHP.  Is that true?  I've always used mail() in the past and I've never been let down in terms of a message *not* being sent.  PHP.net says the same thing as the response from stackoverflow as well.   thanks!

Edited by ajetrumpet
Link to comment
Share on other sites

maxx,

PHPmailer is here:  https://github.com/PHPMailer/PHPMailer.   but i'm not sure what i'm to do with that.  am i spose to download all the files in those directories that are there and then run the PHP composer installer here?  https://getcomposer.org/download/.   I'm not good enuf to understand complex installations like PHP, Python and stuff altho I manage to use Eclipse and Pythons IDEs fairly well.  

Edited by ajetrumpet
Link to comment
Share on other sites

9 hours ago, ajetrumpet said:

scratch that.

OK - I assume the 'installation & loading' section of the readme got you sorted?

Ask any questions you've got on it here, but I can almost guarantee that you'll have a much, much better experience using PHPMailer than you've had using PHP's native mail() function.

Edited by maxxd
Link to comment
Share on other sites

On 11/25/2019 at 9:46 PM, phppup said:

The link you posted does not connect to a definitive article. Please double check it.

I'm not sure which link ur referring to.  the ones from my previous latest post both work fine for me.  

maxx,

I received help from an expert on another site getting PHPMailer to work.  we worked on it for 2 full damn days!   I was getting error and error message after trying to use SMTP and then NOT using SMTP, etc, etc....what ended up being discovered was that apparently, according to the expert helping me, the code in one of the files from the github download package was written incorrectly.  he fixed it and eventually he gave me a solution that was not spammed out when received by the gmail mail server.  thanks for all ur input here guys..


Adam

 

Edited by ajetrumpet
Link to comment
Share on other sites

2 hours ago, ajetrumpet said:

apparently, according to the expert helping me, the code in one of the files from the github download package was written incorrectly

Which file(s)? The only issues I've really run into with PHPMailer involved incorrect email addresses and authentication issues, so I'd be interested to know. Also, make sure there's been an issue submitted to the repo if there's an error in the code.

Link to comment
Share on other sites

I'm not sure I should bother the other dude about where he found the error maxx.  I will send him a PM though and inquire about it.  We went thru so many trial and errors though that it's very possible he just edited the source code to try and make it work with the method we were trying at the time.  but i'll look into it and if there is indeed an error, i'll post at github about it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.