Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

dedicated server not sending mail() or smtp

php, mail, dedicated server, problem

11:13 pm on Mar 3, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:May 10, 2005
votes: 0

Hi guys,

god it's been 5 years since I was last on here but I'm glad to see I can still hopefully get some help.

got a client who we have popped on a dedicated server using cpanel/whm etc.

We normally use their virtual hosting and the other 100+ accounts work fine using the php mail() function.

the problem is :

on the dedicated server mail() will only send mail to an email on the same domain, i.e the contact form works if you send it to info@mydomain.com but if I want to send out a thankyou email to the user it fails as the email address isnt on the same server?

so after 3 hours of screwing around online I ended up downloading PHPMailer and messing with the config.

I thought it might be an issue with not using SMTP and authentication too so I added that (not sure about using PEAR though b4 u ask) but that only works in the same way, I can send to the test email account on the same domain but not to an external email address.

Could it be an mx relay record issue and if so what do I need to do?

Could it be a WHM configuration setting ?

Can I do anything in cpanel to unlock the use of the mail.mydomain.co.uk usage?

Heres my code to use PHPMailer and SMTP :


$mail = new phpmailer;
$mail->IsSMTP(); // set mailer to use SMTP
$mail->AddAddress("me@mydomain.net", "test name");
$mail->AddReplyTo("noreply@sitedomain.co.uk", "Admin");
//$mail->AddAttachment("c:\\temp\\js-bak.sql"); // add attachments
$mail->From = 'noreply@sitedomain.co.uk';
$mail->FromName = 'Tester mail name';
$mail->Host = 'mail.sitedomain.co.uk';
$mail->Mailer = 'smtp';
$mail->Password = 'mypassword';
$mail->Username = 'noreply@sitedomain.co.uk';
$mail->Subject = $mail_subject;
$mail->SMTPAuth = "true";
$mail->Body = $mail_content;

if (!$mail->Send()) {
echo "<p>There was an error in sending mail, please try again at a later time</p>";
echo "<p>".$mail->ErrorInfo."</p>";
} else {
echo "<p>Thanks for your feedback, <em>$name</em>! We will contact you soon!</p>";

hope you guys can help as my hosting company simply "Do not offer support for scripts or configuration, only hardware issues".

Thanks guys :p
12:56 am on Mar 4, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 1, 2003
votes: 0

Sounds like your host is blocking outgoing mail deliberately. (You can try testing your script on another host to be sure the script is not the problem.)

The most common way a host blocks outgoing mail is to block traffic on port 25. You may be able to get around this by finding a web host that accepts SMTP connections on port 26 (or some other port).

You might also Google "php port scanner" to test if your host is indeed blocking your port 25.
4:33 am on Mar 4, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:May 10, 2005
votes: 0

Ok, if it's on a dedicated though surely we can do something to unlock that right? Do you know how I could select a different port to use in phpmailer with smtp?

4:59 am on Mar 4, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:May 10, 2005
posts: 89
votes: 0

Hi again, port 25 is open, why can't i send mail from a dedicated but easily from shared hosting ? Do you k ow if I have to install anything?