Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have encountered a strange problem sending email from php. For some reason, php sendmail function fails to send email to email addresse hosted on localhost, but the one hosted on anther host. I don't know why it doesn't work for localhosted email addresses. The result of the mail function doesn't even show error(I mean false) when the mail function fails to send email to localhosted email addresses. Any idea?

<?php
/********************************************************************
* XPertMailer is a php class that you can use to send encoded *
* MIME type e-mail messages (text, HTML, HTML embeded images, *
* attachments) towards a localhost, client or relay SMTP servers *
* with optional authorisation *
--------- *
* For more informations, please visit: http://www.xpertmailer.com/ *
********************************************************************/@set_time_limit(0);
@error_reporting(E_ALL); // for debugging// you will need to download the latest version of XPertMailer from
// http://sourceforge.net/projects/xpertmailer/
require_once 'XPertMailer.php';/**
* send a complex mail - text/html format
* with two HTML embeded images and two attachment files
------------
*/// $mail = new XPertMailer; // <-- by default SMTP_LOCAL_CLIENT
// but you can optionaly use an relay host (name or ip)
$mail = new XPertMailer(SMTP_RELAY, "relay-host-name.com");// optionaly you can set authentification for relay host
$mail->auth("username", "password");// optionaly you can set time out for each smtp server connection
$mail->timeout(30);// optionaly you can set priority high (default is P_NORMAL - normal)
$mail->priority(P_HIGH);// optionaly you can set from mail address and optionaly from name
$mail->from("my@account.com", "My Name");// optionaly you can set each header name and value
$header['Cc'] = "example1@domain.com";
$header['Bcc'] = "example2@domain.com";
$header['Reply-To'] = "reply@domain.com";
$header['X-Whatever'] = "description";// set additional header informations
$mail->headers($header);// set HTML embedded images name and optionaly you can rename them
// if the file is not in this directory, write the path name
// Attention: do not include path name in the rename
$imgs[] = "image1.jpg";
$imgs['newname.gif'] = "image2.gif";// attach HTML embedded images
$mail->attach($imgs, ATTACH_HTML_IMG);// set attachment files name and optional you can rename them
// if the file is not in this directory, write the path name
$file['new.zip'] = "archive1.zip";
$file[] = "archive2.tar.gz";// attach files
$mail->attach($file, ATTACH_FILE);// set the HTML message value
// Attention: do not include image path name
$html = '
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<body>
<u>next image</u> :-)
message html red here
</body>
</html>';// send the e-mail and optionaly you can set charset value
// as you can see, the text/plain message is required because
// not all mail clients can currently support HTML messages
$send = $mail->send("expertphp@domain.com", "subject here",
"this is a HTML message", $html, "UTF-8");// output -->
// compare the result and print a message
echo $send ? "Done." : "Error.";// some useful for debugging
echo "
Server response: ".$mail->response();?>

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |