Page 1 of 1

Issues in sending Mail via PHP

Posted: Wed Jul 25, 2007 5:07 am
by dream2rule

Code: Select all

<?php
require "Mail.php";

$from = "<admin@something.com>";
$to = "<mail@something.com>";
$subject = "Test Mail";
$body = "Hi,\n\nHow are you?";

$host = "mail.something.com";
//$username = "";
//$password = "";

$headers = array ('From' => $from,  'To' => $to,  'Subject' => $subject);
$smtp = Mail::factory('smtp',  array ('host' => $host,    'auth' => false, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) 
 {
 	 echo("<p>" . $mail->getMessage() . "</p>");
 } 
 else 
 {
	echo("<p>Message successfully sent!</p>");
 }
?>
The above code works but i have only 2 drawbacks with the script -

1) Only plain text can be sent in the body of the email while i want to send the html content.

2) The mail is sent only to a particular domain mail.something.com. Using this script i am unable to sent any emails to yahoo, gmail or for that matter rediffmail.

I would want to send the mail to all the clients i.e, gmail, yahoo, rediffmail, something.com etc...

How do i do it?

Regards,
Dream2rule

Warning message experienced :(

Posted: Wed Jul 25, 2007 6:37 am
by dream2rule
Warning: mail() [function.mail]:
SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

Posted: Wed Jul 25, 2007 8:01 am
by superdezign
Dare I say it? Swiftmailer.

Also, make sure your credentials are correct.