APD Toronto
asked on
PHPMailer
Hello Experts,
I just downloaded PHPMailer from https://github.com/PHPMailer/PHPMailer and copied/pasted the code from the "a simple example" section, but I keep getting:
Message could not be sent.Mailer Error: SMTP connect() failed.
Thank you
I just downloaded PHPMailer from https://github.com/PHPMailer/PHPMailer and copied/pasted the code from the "a simple example" section, but I keep getting:
Message could not be sent.Mailer Error: SMTP connect() failed.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Use
$mail->Password = 'pa$$word'; // note the apostrophes instead, easier to read
2. Not sure, too many years since I last used it,
The port is the likely culprit, if you copied it verbatim, as the error is it cannot even connect to the server
$mail->Password = 'pa$$word'; // note the apostrophes instead, easier to read
2. Not sure, too many years since I last used it,
The port is the likely culprit, if you copied it verbatim, as the error is it cannot even connect to the server
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I removed the escape characters from my password and everything else is single-quoted, but the error remains the same.
I am using $mail->Port = 2;, which may seem odd, but that is what would in CDOSYS
Any further feedback would be appreciated.
I am using $mail->Port = 2;, which may seem odd, but that is what would in CDOSYS
Any further feedback would be appreciated.
And that is open in the firewall and PHP has access to it, it may be restricted only to the CDO component using it?
That port number is extremely likely to be wrong, or a correct value for an unrelated parameter. Typical values will be 25, 465, 587, and occasionally you'll see 2525, 2500 etc.
ASKER
I have tried all port numbers from above, the result is the same
Firewall...?
ASKER
I am emailing the hosting company now, will keep you posted.
If any other ideas in the mean time, please share.
If any other ideas in the mean time, please share.
If you saw the link I originally posted, it had a troubleshooting sequence for exactly this problem. The key is to test outside PHPMailer before trying to fix it inside. Check that your DNS is working, that the target SMTP server responds to pings and you can telnet to it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Reposting what others have already said isn't very helpful.
Depends on your perspective! In my defence your Honour, when I started there weren't any responses but then children being sick everywhere distracted me somewhat...
ASKER
I hear back from the hosting provider and they changed some credentials, and worked. However, I have the following question for you
1. I had my $mail->Host = 'mail.mydomain.com', but my script is at 'test.mydomain.com', so they changed this to 'test.mydomain.com'. Does this mean the domain were my script resides, and if I wanted it in my primary domain, it wont just be 'mydomain.com'?
2. For $mail->Username I was using 'donotreply@myotherdomain. com' with appropriate password, but they changed it to an address @mydomain.com. Does this means that I cannot use an address to authenticate from another domain (same server)?
3. I realize that under $mail->FromName I can have any email address, but when the email is received, it says that address followed by <root@localhost>. Can <root@localhost> be changed?
4. Even though this script works with the changed credentials on the server, it doesn't work from my local machine. Even though not important, it would be nice.
Thank you
1. I had my $mail->Host = 'mail.mydomain.com', but my script is at 'test.mydomain.com', so they changed this to 'test.mydomain.com'. Does this mean the domain were my script resides, and if I wanted it in my primary domain, it wont just be 'mydomain.com'?
2. For $mail->Username I was using 'donotreply@myotherdomain.
3. I realize that under $mail->FromName I can have any email address, but when the email is received, it says that address followed by <root@localhost>. Can <root@localhost> be changed?
4. Even though this script works with the changed credentials on the server, it doesn't work from my local machine. Even though not important, it would be nice.
Thank you
1. The Host value is the FQDN of your mail server, not necessarily the same server that your script is running on. It would be unusual for the mail server to use just the bare domain, and not some hostname like mail, test etc.
2. Authentication within a single mail server generally isn't that bothered about which domain you authenticate with (certainly mine isn't), so long as you can authenticate, it will allow you to relay mail through it.
3. There is a From property as well as FromName - also look at the setFrom method.
4. That sounds like a connectivity problem.
2. Authentication within a single mail server generally isn't that bothered about which domain you authenticate with (certainly mine isn't), so long as you can authenticate, it will allow you to relay mail through it.
3. There is a From property as well as FromName - also look at the setFrom method.
4. That sounds like a connectivity problem.
1. This is the mail server address, not your address
2. This will depend on what the mail server is expecting, it won't accept an email address it doesn't recognise (at least it shouldn't)
3. Can be anything you like, doesn't matter
4. Check the firewall, your port is unusual
2. This will depend on what the mail server is expecting, it won't accept an email address it doesn't recognise (at least it shouldn't)
3. Can be anything you like, doesn't matter
4. Check the firewall, your port is unusual
ASKER
@Gary
>>3. Can be anything you like, doesn't matter
How?
>>3. Can be anything you like, doesn't matter
How?
It's just the From Name - could be your name, or anything.
$mail->From = 'myfromaddress@example.com ';
$mail->FromName = 'My From Name';
or to set both name and address:
$mail->setFrom('myfromaddr ess@exampl e.com', 'My From Name');
$mail->FromName = 'My From Name';
or to set both name and address:
$mail->setFrom('myfromaddr
ASKER
1. My password has some reserved characters like pa$$word, so I am using
$mail->Password = "pa\$\$word";
2. My CDO SYS has the following
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
I am assuming this is equivalent to $mail->SMTPSecure, but I am not sure what is 1 equivalent to?