homepage Welcome to WebmasterWorld Guest from 54.145.243.51
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
dedicated server not sending mail() or smtp
php, mail, dedicated server, problem
diegomh7

5+ Year Member



 
Msg#: 4276294 posted 11:13 pm on Mar 3, 2011 (gmt 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 :

require("phpmailer/phpmailer.inc.php");

$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->AddAttachment("c:/temp/11-10-00.zip");
$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

 

timster

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4276294 posted 12:56 am on Mar 4, 2011 (gmt 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.

diegomh7

5+ Year Member



 
Msg#: 4276294 posted 4:33 am on Mar 4, 2011 (gmt 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?

Thanks

diegomh7

5+ Year Member



 
Msg#: 4276294 posted 4:59 am on Mar 4, 2011 (gmt 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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved