|
 |
beginning_php thread: SMTP issue
Message #1 by "Srinivasan Prasanna" <Sri_core@m...> on Wed, 2 Oct 2002 01:17:41
|
|
I have some issues with my SMTP setting I think. I am not positive how I
will be able to get error msgs from the server. I have this statement
die ("Couldn't open mail connection to server! \n");
This does not error out so I am thinking my 4smtp_server is not an issue.
Code:
<?PHP
function sendmail($name, $from, $to, $subject, $body, $html, $charset )
{
$smtp_server = "mail.servername.com";
if (!$smtp_sock = fsockopen("$smtp_server", 25))
{
die ("Couldn't open mail connection to server! \n");
}
fputs($smtp_sock, "HELO $smtp_server\n");
fputs($smtp_sock, "VRFY $smtp_server\n");
fputs($smtp_sock, "MAIL FROM:<$from>\n");
fputs($smtp_sock, "RCPT TO:<$to>\n");
fputs($smtp_sock, "DATA\n");
fputs($smtp_sock, "From: $name($from)\n");
fputs($smtp_sock, "X-Mailer: emailer1.0\n");
if ($html)
fputs($smtp_sock, "Content-Type: text/html;");
else
fputs($smtp_sock, "Content-Type: text/plain;");
fputs($smtp_sock, "charset=$charser\n");
fputs($smtp_sock, "MIME-Version: 1.0\n");
fputs($smtp_sock, "Subject: $subject\n");
fputs($smtp_sock, "To: $to\n");
fputs($smtp_sock, "$body");
fputs($smtp_sock, "\n.\nQUIT\n");
fclose($smtp_sock);
}
?>
</body>
</html>
Any thoughts/help.
Thanks
Sri
Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 1 Oct 2002 17:15:00 -0700
|
|
I don't know too much about mail headers, but you've misspelled $charset in
your fputs call. Maybe that has something to do with the failure.
> fputs($smtp_sock, "charset=$charser\n");
hth
nik
Message #3 by "Srinivasan Prasanna" <Sri_core@m...> on Wed, 2 Oct 2002 01:43:00
|
|
Thanks for your sharp eyes Nik. But that did not help solve though.
Thanks
Sri
>
I don't know too much about mail headers, but you've misspelled $charset in
your fputs call. Maybe that has something to do with the failure.
> fputs($smtp_sock, "charset=$charser\n");
hth
nik
Message #4 by "Srinivasan Prasanna" <Sri_core@m...> on Wed, 2 Oct 2002 02:06:12
|
|
I tried send mail too and it fails
This did not work either
{
xmail("<4to>\n", "Subject:$subject\n", $body,
"From: <$from>\n"
."Reply-To: webmaster@$SERVER_NAME\r\n"
."X-Mailer: emailer1.0\n");
Am I missing any logic here?
Thanks
Sri
> Thanks for your sharp eyes Nik. But that did not help solve though.
> Thanks
S> ri
> >
I> don't know too much about mail headers, but you've misspelled $charset
in
y> our fputs call. Maybe that has something to do with the failure.
> > fputs($smtp_sock, "charset=$charser\n");
> hth
> nik
Message #5 by "Nikolai Devereaux" <yomama@u...> on Tue, 1 Oct 2002 18:09:09 -0700
|
|
Well, the "to" field should be either an email address or "name <email>". I
don't think you should add newlines in those fields.
I think this has been mentioned every time someone's had a problem with xmail().
Get a simple message to send properly, then start worrying about adding
headers. There's too many things that can be screwed up (e.g. \r\n vs. \n).
Good luck,
nik
|
 |