Mail() problems, yesterday it worked


#1

yesterday this code worked wonderfully but now i dont receive any mails anymore when i wanted to test a new script of mine that needed mail, i did not do any changes in the dreamhost panel so i dont see any reasons for mail() not to work …
i get the output sended but no mail arrived on yahoo or gmail …
[php]<?php
$to = ‘a_mail@yahoo.com’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = ‘From: no-replay@domain.com’ . “\r\n” .
‘Reply-To: webmaster@domain.com’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

if (mail($to, $subject, $message, $headers)) {
echo “sended”;
}else{
echo “wtf error”;
}
?>[/php]
[hr]
and there are no mail logs …
[hr]
i tried with this, changed the code a bit still does not work

[php]$to = ‘a_mail@yahoo.com’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = “From: MR Alert webmaster@domain.com\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “X-Mailer: PHP/” . phpversion()."\r\n";

if (mail($to, $subject, $message, $headers)) {
echo “sended”;
}else{
echo “error”;
}[/php]

i see no reason for it not to work when i know for sure that it worked yesterday, i am not happy with this


#2

I’m actually having the same issues. (In fact I just registered to these forums to ask this same thing!)


#3

I’m having the same issue with my site. It worked Friday, didn’t work Sunday, didn’t work this morning when I ran tests, but it just started working as of tests ran at 12:43PM est and 12:53PM est.

I’ve submitted a supported ticket that’s about three hours old now. Haven’t received an email confirmation from Dreamhost that I submitted the ticket and haven’t received a response from support at the time of this post.

Emails have been working all morning, though. Not sure what’s up.

EDIT

Just received a response from support. Apparently their mail relay servers were backlogged. In order to avoid this, send emails using SMTP authentication which will then use their actual SMTP servers.

Looks like you’ll need to include code to use STMP authentication in order to avoid this problem.

As a start, I found this: http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm


#4

does the mail() function work now?


#5

It never stopped working :wink:

If you’d rather step up to SMTP then phpMailer is the duck’s guts.


#6

I’m not sure about “duck’s guts”, but yahoo has sent me a T503 (forever banned) since I started using phpMailer. But actually, that’s prolly just coincidence,… I think it has more to do with the server move to the east coast.


#7

phpMailer will not get anyone permabanned from anywhere.

/conspiracy


#8

okay guys, i tried php mailer, i can not make it work at all, readed the documentation on wiki about php mailer and dream host, it did not work like that, i tried to find some examples on the internet on how other have implemented phpmailer to use it with dream host and failed, can any one please give me a working script that works on dream host?
[hr]
this is what i did until now, it always returns Message could not be sent. why? what is it wrong?
[php]<?php
require(“lib/phpmailer/phpmailer.inc.php”);
$mail = new PHPMailer();

$mail->IsSMTP();                             // set mailer to use SMTP
$mail->Host = "mail.myDomain.com";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
    $mail->Username = "user";        // Make sure to replace this with your shell enabled user
    $mail->Password = "pass";      // Make sure to use the proper password for your user

	
$mail->From = "me@mydomain";
$mail->FromName = "Your Name";
$mail->AddAddress("reciver@yahoo.com", "Their Name");

$mail->AddReplyTo("me@mydomain", "me");
		
$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML
		
$mail->Subject = "PHPmailer example";
$mail->Body    = "This is a test of email";
					
if(!$mail->Send()){
	echo "Message could not be sent. <p>";
	echo "Mailer Error: " . $mail->ErrorInfo;
	exit;
}

?>[/php]


#9

SMTP can send emails through two different servers:
mail.your_domain.com – login with a mail account username & password
localhost – login with a web server user (ftp/shell) username & password

The combination of “$mail->Host = “mail.myDomain.com”; " and " $mail->Username = “user”; // Make sure to replace this with your shell enabled user” make us think you might be using the wrong user/password for the server you’re trying to use.

The example code you’re using from our PHPMailer wiki page has the “localhost” server, so the comment about “shell enabled user” is fine, but when you replaced that with your actual mail server, you needed to switch to using a username & password that works on the actual mail server, which means a mail account username & password.

Switching away from localhost is fine, but you’ve got to use a mail account username & password with it. :slight_smile:

Also, one of our lovely tech supporters just responded to your submitted ticket! Please reply there directly with the requested details so we can further look into your issue. Thanks!