0

I'm trying to send mail out from an external smtp server using a php script below,

<?php
$recipient="john_doe@gmail.com"; 
$subject="Website to customer";
$message="Customer Name: ".$_POST['name']."\r\n";
$message.="Customer Email: ".$_POST['email']."\r\n";
$message.="Customer Message: ".$_POST['msg']."\r\n"; 
$mailheader="From: <maria@comcast.net> \r\n";
$mailheader.="Reply to ".$_POST['email'];
ini_set("SMTP","comcast.net");
mail($recipient, $subject, $message, $mailheader);
?>
<!DOCTYPE html>
<html>
<head>
<title>Sending mail from website to Customer</title>
</head>
<body>
<p>Thanks, <strong><?php echo $_POST['name']; ?></strong>, for your message.</p>
<p>Your email address: <strong><?php echo $_POST['email']; ?></strong></p>
<p>Your message: <br/><?php echo $_POST['msg']; ?></p>
</body>
<html>

I got an error message:

Warning: mail() [function.mail]: Failed to connect to mailserver at "comcast.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\sendmail.php on line 10

Is that because I don't have a local email server? Will phpmailer solve my problem? Can anyone guide me to the right direction please? Thanks a lot.

borrible
  • 17,120
  • 7
  • 53
  • 75
Maria Genko
  • 31
  • 1
  • 2
  • 7
  • The error could be literal. It could be that comcast is blocking outgoing port 25 connections for spam reasons. They might have a different port you can use like 2525. – Uberfuzzy Apr 08 '13 at 23:39
  • possible duplicate of [Warning: mail() \[function.mail\]: Failed to connect to mailserver](http://stackoverflow.com/questions/7011300/warning-mail-function-mail-failed-to-connect-to-mailserver) – hjpotter92 Apr 09 '13 at 07:19
  • Not the same as the possible duplicate since it's not localhost here. – Shikiryu Apr 09 '13 at 07:57

2 Answers2

2

Yeah. 5 seconds on google found this, http://customer.comcast.com/help-and-support/internet/list-of-blocked-ports/

use port 465. You may need to setup account information to send outgoing on their servers too.

Uberfuzzy
  • 8,253
  • 11
  • 42
  • 50
  • I changed the port to 465 in php.ini and restarted Apache. Funny thing is I got the same error message as if I was stilling using port 25. Did I miss anything? What do you mean "setup account information to send outgoing on their servers"? Thanks. Maria. – Maria Genko Apr 09 '13 at 00:48
  • See @Andrzej's answer, it has more correct details. Search around this site (bunch in the related questions sidebar) for sending using SMTP + google mail for the php packages you'll need. Then just use the comcast server & port. – Uberfuzzy Apr 09 '13 at 06:49
1

Use smtp.comcast.net instead of comcast.net as SMTP parameter. Set smtp_port parameter to 587.
BUT Page [2] suggests that you will need SMTP AUTHentication not suported by php-mail. See page [3] for available alternatives.

URL(s):
1. http://www.php.net/manual/en/mail.configuration.php
2. http://customer.comcast.com/help-and-support/internet/email-client-programs-with-xfinity-email/
3. php.ini & SMTP= - how do you pass username & password

Community
  • 1
  • 1
AnFi
  • 10,493
  • 3
  • 23
  • 47
  • I've tried port 465 and 587. But I still got the same error message as if I was stilling using port 25. I restarted Apache, restarted my computer, but it keeps saying "Warning: mail() [function.mail]: Failed to connect to mailserver at "comcast.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\sendmail.php on line 10". This is so frustrating. – Maria Genko Apr 10 '13 at 00:07
  • Do you get SMTP greeting when you you telnet the ports? `telnet smtp.comcast.net 587` – AnFi Apr 10 '13 at 06:22
  • I'm using Microsoft Telnet in Windows. When I typed in "telnet smtp.comcast.net 587", it says invalid command. What should be the right command? Thanks, Andrzej. – Maria Genko Apr 10 '13 at 21:24
  • The telnet message is "220 omta11.westchester.pa.mail.comcast.net comcast ESMTP server ready Connection to host lost." I guess that means there is no connection. What can I do now? – Maria Genko Apr 10 '13 at 23:28