ajetrumpet Posted November 21, 2019 Share Posted November 21, 2019 (edited) 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 November 21, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/ Share on other sites More sharing options...
maxxd Posted November 21, 2019 Share Posted November 21, 2019 2 hours ago, ajetrumpet said: one of the responders suggests using PHPMailer as a better way to send mail using PHP. Is that true? Yes. Entirely and completely. Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1571767 Share on other sites More sharing options...
ajetrumpet Posted November 21, 2019 Author Share Posted November 21, 2019 (edited) 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 November 21, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1571769 Share on other sites More sharing options...
ajetrumpet Posted November 21, 2019 Author Share Posted November 21, 2019 sorry, stupid question. scratch that. Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1571784 Share on other sites More sharing options...
maxxd Posted November 22, 2019 Share Posted November 22, 2019 (edited) 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 November 22, 2019 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1571800 Share on other sites More sharing options...
phppup Posted November 26, 2019 Share Posted November 26, 2019 The link you posted does not connect to a definitive article. Please double check it. Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1571898 Share on other sites More sharing options...
ajetrumpet Posted December 1, 2019 Author Share Posted December 1, 2019 (edited) 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 December 1, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1572059 Share on other sites More sharing options...
maxxd Posted December 1, 2019 Share Posted December 1, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1572061 Share on other sites More sharing options...
ajetrumpet Posted December 1, 2019 Author Share Posted December 1, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309560-setting-smtp-in-phpini-to-make-mail-function-work/#findComment-1572062 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.