Jump to content

Using the mail function to send a message to a cell phone


VTS

Recommended Posts

Hello,

 

I have a program that emails me whenever it gets errors.  Since I am not always able to check my email and monitor it, I figured I would set it up to send a message to my phone on the weekends whenever it has errors.  My problem is that for some reason I cannot get the mail function to send messages to my phone at all.  I am using my company email as the from address.  Is is just that the mail function cannot send messages to vtext accounts or am I just doing something wrong?  I can just change the from address to a regular email and it works just fine.  I can also send the messages from my company email to my phone but anytime I try to send it with the mail function it does not work.  I have tried using the function like this:

 

mail('[email protected]', 'subject', 'message');

 

and like this as well:

 

mail('[email protected]','subject', 'message', 'From: [email protected]');

 

I tried to search a little for this but kept getting error when searching this site so i decided to post here.

 

Thanks in advance for the help

UPDATE: I can send email to my company email addresses but not to any outside emails ie yahoo, hotmail, gmail.  I am guessing this means I am missing some kind of information that would allow a server to see where the email is coming from.  I still am not sure what I should do.

They might be filtering the message as SPAM. There are certain headers that must exist or certain servers will mark them as spam. I had a function that included all of them, but sadly it's at my home computer. If this isn't resolved by the time I get home I'll post it here.

 

It could also be the sendmail setup on your server. It might not allow PHP/Apache/IIS to send mail to outside servers.

Ok, I just checked and there is nothing on my end that is blocking any outgoing mail.  I also added 'or die("could not send message")'  to the end of the mail clause and when I ran it, I got the could not send message error.  I will try that phpmailer class and see how that works too.

UPDATE:  I have been trying to get the PHP mailer to work since yesterday with no luck.  I keep getting the error "could not connect to smtp host" Here is the code I am using:

 

<?php


require(".\\phpmailer_v2.0.0\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "smtp.mycomanysmtp.com";  // specify main and backup server
$mail->SMTPAuth = false;     // turn on SMTP authentication
$mail->Username = "";  // SMTP username
$mail->Password = ""; // SMTP password

$mail->From = "[email protected]";
$mail->FromName = "david";
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");                  // name is optional
$mail->AddReplyTo("[email protected]");

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

?>

 

 

I have tried using this funciton with and without authentication and I get the same error every time.  Anyone have any ideas?

I think it may be working for mails within your company, as the mails may not need to pass through the SMTP server to get to internal mails, because they are internal! SMTP is what is used to send them out.

 

As for your problem - you need to make sure the SMTP server is set correctly. You may (and probably) also need to create the email address you are sending the emails from, if it doesnt already exist. You may also need to give the username and password for that account in order to send the mail.

Ok, I fixed the cannot connect to smtp server error and now I am getting an error stating that my helo address is invalid.  What am I supposed to put in there?  If I don't put anything, it tells me it doesn't accept mail from my ip and to "bugger off".  If I put my smtp in there, it tells me that my helo address is invalid. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.