Forum Moderators: coopster
If I use a script that has a mail() function and the address is to an address of the same domain as the site, it works ok. If it is to an outside address, it disappears. Though it returns it was a successful send.
Do I have some security feature enabled that is unknown to me? (A lot is unknown to me. LOL)
Thanks for any help!
/var/log/mail/mail.log; or
/var/log/mail.log
Using mail() worked fine for any address, but sometime in the last few months something happened and I'm only able to send mails to my domain. The mails are being delivered to sendmail, as the function is returning a boolean of true.
It's definitely not a problem with receiving the emails client side. My ISP isn't responding to support emails, and without root access to check the sendmail logs, I'm out of options.
I am however, able to send mails normally using Perl, as below:
open ( MAIL,"¦/usr/sbin/sendmail -t");
print MAIL "To: myname\@gmail.com\n" ;
print MAIL "From: visitor\@hisdomain.com\n" ;
print MAIL "Subject: Comments from Web Form\n\n" ;
print MAIL "What a message!" ;
close ( MAIL ) ;
Thanks for the input everyone.
The fact I an do it in Perl leads me to think something isn't configured properly in PHP.
While the above lines work in Perl, as with mail(), this function wont deliver mails other than to the domain:
function newMail($to,$subject,$message,$headers) {
$mail = popen("/usr/sbin/sendmail -t", "w");
fputs($mail, "To: $to\n");
fputs($mail, "$headers\n");
fputs($mail, "Subject: $subject\n\n");
fputs($mail, $mess);
fclose($mail);
}
Ie the script was running as a user with too low permissions in respect of sendmail, afair.
(wouldn't even call this my own $0.02, just $0.01, but I hope it helps)
best, a.
They have done the same thing because people have been abusing their servers with mail scripts, so when they upgraded to new servers they changed their settings so that the mail function would only work to domain addresses. Sounds like yours have done the same.
I got around it by using the PHP mailer.
http://phpmailer.sourceforge.net/ [phpmailer.sourceforge.net]
dc
class.phpmailer.php and class.smtp.mailer into my apache root directory, alongside the phpmailer installation folder: require("class.phpmailer.php"); require("class.smtp.php"); if ($to_email) { # SEND MAIL $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "mail.mydomain.com"; $mail->SMTPAuth = true; $mail->Username = $phpuname; $mail->Password = $phppassw; $mail->SetLanguage("en","/var/www/phpmailer/language/"); $mail->From = "user@mydomain.com"; $mail->FromName = "User"; $mail->AddAddress($to_email,$to_name); $mail->AddReplyTo("user@mydomain.com","User"); $mail->Subject = $to_subject; $mail->Body = $mail_body; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; }} Might be helpful. I had to gather stuff from a couple of locations to put that together.
PHPMailer was successful for mailing my domain, but recieved this error for other domains:
"Message was not sentMailer Error: Language string failed to load: recipients_failedmyemail@somedomain.com"
The Perl script still works though, it doesnt work if it's called from a PHP script, I get the Hello World I put in it but it doesn't send the mail.
Are there any other ways of using the Perl mail functionality without rewriting my scripts in Perl?