简体   繁体   中英

PHP () Mail & SMTP Issues

I know this question has been asked a million times, but i have been trying to find a solution to my problem for almost 18 hours - straight!

So stressful...

It's a long one, but i have tried to give you as much info on the different things that might be causing my errors.

I had my current website irishgroupage.co.uk set up on my own hosting account with WHMCS and everything was working fine. I switched to the companies main hosting provider who was previously hosting the old html website and now i cannot get the mailer to work.

The wordpress default PHP mailer and the SMTP settings are completely knackered for some reason.

It started with it not being able to connect to any SMTP server, even though i know for a fact my own hosting allows this - as it worked last night and the day before with no issues. It is also working with a few clients i have set up on my own server - so no issues with my email service.

The default PHP mailer worked as well by just putting in our gmail email.

So after several attempts at getting this to work, i now get this error;

 SMTP -> ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it. (10061) 

I'm not sure if maybe my domain has been blacklisted now due to too many attempts; maybe been flagged for spam? But i now get this error with every email account and SMTP account i use on this domain.

In my own hosting the website was in the Public_html directory, however i can't put it in the current Public_html directory because i then get a 403 forbidden error page when loading the website. This hosting company must have some security thing going on there

In my own hosting we have the mail directory and in this one i have the mail directory as well as a php folder with a php mailer folder in there too. I'm wondering if maybe these 2 directories are clashing with the wp-mail file as the whole website is in the root of the ftp account.

So to make it clear how my site is set up in the FTP

Current hosting

  • PHP - contains the PHP-Mailer
  • Mail - Contains my emails
  • Public_html - Contains nothing
  • All of my website files, including the wp-mailer file.

Old hosting

  • Mail - Contains my emails
  • Public_html - All of my website files

I would switch back to my own hosting but i can't seem to set up the exchange server, so that's not an option just now.

You can see the full error report below

 Test Message Sent The result was: bool(false) The full debugging output is shown below: object(PHPMailer)#4484 (69) { ["Version"]=> string(5) "5.2.7" ["Priority"]=> int(3) ["CharSet"]=> string(5) "UTF-8" ["ContentType"]=> string(10) "text/plain" ["Encoding"]=> string(4) "8bit" ["ErrorInfo"]=> string(22) "SMTP connect() failed." ["From"]=> string(23) "irishgroupage@gmail.com" ["FromName"]=> string(23) "Irish Groupage Services" ["Sender"]=> string(0) "" ["ReturnPath"]=> string(0) "" ["Subject"]=> string(51) "WP Mail SMTP: Test mail to andy@irishgroupage.co.uk" ["Body"]=> string(68) "This is a test email generated by the WP Mail SMTP WordPress plugin." ["AltBody"]=> string(0) "" ["Ical"]=> string(0) "" ["MIMEBody":protected]=> string(69) "This is a test email generated by the WP Mail SMTP WordPress plugin. " ["MIMEHeader":protected]=> string(463) "Date: Sun, 18 Jan 2015 02:08:42 +0000 Return-Path: To: andy@irishgroupage.co.uk From: Irish Groupage Services Subject: WP Mail SMTP: Test mail to andy@irishgroupage.co.uk Message-ID: <69cde0c871a661784c186899491037c4@irishgroupage.co.uk> X-Priority: 3 X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit " ["mailHeader":protected]=> string(0) "" ["WordWrap"]=> int(0) ["Mailer"]=> string(4) "smtp" ["Sendmail"]=> string(18) "/usr/sbin/sendmail" ["UseSendmailOptions"]=> bool(true) ["PluginDir"]=> string(0) "" ["ConfirmReadingTo"]=> string(0) "" ["Hostname"]=> string(0) "" ["MessageID"]=> string(0) "" ["MessageDate"]=> string(0) "" ["Host"]=> string(14) "smtp.gmail.com" ["Port"]=> string(3) "587" ["Helo"]=> string(0) "" ["SMTPSecure"]=> string(3) "tls" ["SMTPAuth"]=> bool(true) ["Username"]=> string(23) "irishgroupage@gmail.com" ["Password"]=> string(12) "" ["AuthType"]=> string(0) "" ["Realm"]=> string(0) "" ["Workstation"]=> string(0) "" ["Timeout"]=> int(10) ["SMTPDebug"]=> bool(true) ["Debugoutput"]=> string(4) "echo" ["SMTPKeepAlive"]=> bool(false) ["SingleTo"]=> bool(false) ["SingleToArray"]=> array(0) { } ["do_verp"]=> bool(false) ["AllowEmpty"]=> bool(false) ["LE"]=> string(1) " " ["DKIM_selector"]=> string(0) "" ["DKIM_identity"]=> string(0) "" ["DKIM_passphrase"]=> string(0) "" ["DKIM_domain"]=> string(0) "" ["DKIM_private"]=> string(0) "" ["action_function"]=> string(0) "" ["XMailer"]=> string(0) "" ["smtp":protected]=> object(SMTP)#4485 (12) { ["Version"]=> string(5) "5.2.7" ["SMTP_PORT"]=> int(25) ["CRLF"]=> string(2) " " ["do_debug"]=> bool(true) ["Debugoutput"]=> string(4) "echo" ["do_verp"]=> bool(false) ["Timeout"]=> int(10) ["Timelimit"]=> int(30) ["smtp_conn":protected]=> bool(false) ["error":protected]=> NULL ["helo_rply":protected]=> NULL ["last_reply":protected]=> string(0) "" } ["to":protected]=> array(1) { [0]=> array(2) { [0]=> string(24) "andy@irishgroupage.co.uk" [1]=> string(0) "" } } ["cc":protected]=> array(0) { } ["bcc":protected]=> array(0) { } ["ReplyTo":protected]=> array(0) { } ["all_recipients":protected]=> array(1) { ["andy@irishgroupage.co.uk"]=> bool(true) } ["attachment":protected]=> array(0) { } ["CustomHeader":protected]=> array(0) { } ["lastMessageID":protected]=> string(54) "<69cde0c871a661784c186899491037c4@irishgroupage.co.uk>" ["message_type":protected]=> string(5) "plain" ["boundary":protected]=> array(3) { [1]=> string(35) "b1_69cde0c871a661784c186899491037c4" [2]=> string(35) "b2_69cde0c871a661784c186899491037c4" [3]=> string(35) "b3_69cde0c871a661784c186899491037c4" } ["language":protected]=> array(18) { ["authenticate"]=> string(35) "SMTP Error: Could not authenticate." ["connect_host"]=> string(43) "SMTP Error: Could not connect to SMTP host." ["data_not_accepted"]=> string(30) "SMTP Error: data not accepted." ["empty_message"]=> string(18) "Message body empty" ["encoding"]=> string(18) "Unknown encoding: " ["execute"]=> string(19) "Could not execute: " ["file_access"]=> string(23) "Could not access file: " ["file_open"]=> string(33) "File Error: Could not open file: " ["from_failed"]=> string(35) "The following From address failed: " ["instantiate"]=> string(36) "Could not instantiate mail function." ["invalid_address"]=> string(15) "Invalid address" ["mailer_not_supported"]=> string(25) " mailer is not supported." ["provide_address"]=> string(54) "You must provide at least one recipient email address." ["recipients_failed"]=> string(45) "SMTP Error: The following recipients failed: " ["signing"]=> string(15) "Signing Error: " ["smtp_connect_failed"]=> string(22) "SMTP connect() failed." ["smtp_error"]=> string(19) "SMTP server error: " ["variable_set"]=> string(30) "Cannot set or reset variable: " } ["error_count":protected]=> int(2) ["sign_cert_file":protected]=> string(0) "" ["sign_key_file":protected]=> string(0) "" ["sign_key_pass":protected]=> string(0) "" ["exceptions":protected]=> bool(true) } The SMTP debugging output is shown below: SMTP -> ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it. (10061) 

If anyone can help me, please do. I'm receding at an extraordinary rate right now!

Just so you are aware, i have deleted the mail and PHP directories and tried again to see if they were clashing, but to no avail; i still got the same error report :(

Thanks guys

I think you need to do a POP3 Authentication before sending (ran into this myself.)

See this example

Pay attention to line 11. In the link they do it a little different, but this is how I did it:

$pop = new POP3();
$pop->Authorise($host, $port, $timeout, $username, $password, 1);

If your outgoing SMTP server requires authentication, you need to do a POP3 authentication before sending.

Then run everything else you were already doing.

["Username"]=> string(23) "irishgroupage@gmail.com"

You are sending mail from irishgroupage@gmail.com

["AuthType"]=> string(0) ""

Without any authentication - ie no credentials to prove who you are. Of course Gmail is not going to connect with you.

But that may not be your only problem. You haven't mentioned if the ports on your server are open or not. Your host may have firewalled you and that could be the cause of the connection issue.

Install this plugin: https://wordpress.org/plugins/postman-smtp/ and use the setup wizard. It will test your ports to find out which ones are open and then configure itself for sending messages to Gmail properly.

You can go to this link after login with the email ID that sending email...

Here, trun on logging for less secure apps: https://www.google.com/settings/u/1/security/lesssecureapps

Here, just click continue... https://accounts.google.com/b/0/DisplayUnlockCaptcha

And check here is there any logging to your account: https://security.google.com/settings/security/activity?hl=en&pli=1

And, run your code.. Hope it helps you..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM