Jump to content

Funcao Mail


bytemania
 Share

Recommended Posts

Hi

Tenho o seguinte problema

Tenho o ubuntu 9.04 e queria enviar um mail vai php

tenho instalado:

  • PHP 5.2.6-3ubuntu4.1
  • Server version: Apache/2.2.11 (Ubuntu)
  • send mail

No ficheiro php.ini tenho a seguinte configuração

sendmail_path = /usr/sbin/sendmail  

Ao executar nmap:

nmap -sT localhost

Tenho o seguinte output:

22/tcp   open  ssh
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
110/tcp  open  pop3
139/tcp  open  netbios-ssn
143/tcp  open  imap
445/tcp  open  microsoft-ds
587/tcp  open  submission
631/tcp  open  ipp
...

Ao executar o a função php esta falha

$to = "bytemania@gmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>

ou seja dá como resultado Message delivery failed

o log da /var/log/mail.log

tail -f /var/log/mail.log

Jun 17 23:36:02 ubuntu sm-mta[14592]: n5HMa2nO014591: to=<www-data@ubuntu>, ctladdr=<www-data@ubuntu> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30842, dsn=2.0.0, stat=Sent

Ficava muito grato se alguem me pudesse ajudar

Também possuo um router na minha ligação a internet

Link to comment
Share on other sites

Boas Sérgio

experimenta na linha de comandos mandar o mail

$> mail -s "subject" endereço@email.com

Corpo 
da 
mensagem

e no fim terminas com Ctrl+D

e vê se o email chega ao destino

já agora, eu tenho um script php para emails que é assim:

require_once 'Mail/mime.php';
require_once 'Mail.php';

$email = new Mail_mime();
$email->setFrom($from);
$email->setSubject($subject);
$email->setTxtBody($message);

$encoded_to = $email->encodeRecipients($to);
$body = $email->get();
$headers = $email->headers();

$sendmail = Mail::factory("mail");
$sendmail->send($encoded_to, $headers, $body);
Tharis Fan ClubMay Tharis bless you
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.