Issues in sending Mail via PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Issues in sending Mail via PHP

Post 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
dream2rule
Forum Contributor
Posts: 109
Joined: Wed Jun 13, 2007 5:07 am

Warning message experienced :(

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Dare I say it? Swiftmailer.

Also, make sure your credentials are correct.
Post Reply