Re: [PHP] Mailer Class help
I had that same problem, download phpMailer.
It's cool. The problem is that when you use mail(); with PHP, not all the data needed is sent. It often arrives in spam, or not at all due to security reasons.
But then I came here, and that mod guy told me to use PHPMailer.
I installed it, and it works! Now I have HTML allowed emails, static email compatible, and all those cool functions that go with email that I never even knew about!
Edit: Oh I just saw that you said something about having tried PHPMailer...
So try this code I use to send mail with PHPMailer (for registration):
PHP Code:
<?php
//Send Email
$activePath="http://www.avsbest.com/...";
$to="$email";
$from="Support@AVsBest.com";
$subject="AVsBest.com - Last Step: Registration Email";
//HTML style message
$message="Thank-You for registering at AVsBest.com!
The information displayed below is all we know about you so far. Please take a moment to make sure this information is correct, than click the link below to finish creating your account.
<br><br>
<a href='$activePath'>$activePath</a>
<br><br>
<b>User Data:</b><br>
Username: $username<br>
Password: Hidden
<hr>
<b>Address</b><br>
Street: $street<br>
City: $city<br>
Zip Code: $zip
<hr>
Email Address: $email";
//plain text message
$message2="Thank-You for registering at AVsBest.com!
The information displayed below is all we know about you so far. Please take a moment to make sure this information is correct, than click the link below to finish creating your account.
$activePath
User Data:
Username: $username
Password: Hidden
--------------------
Address
Street: $street
City: $city
Zip Code: $zip
--------------------
Email Address: $email";
?>
<?php
include_once('../phpMailer/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = $message;
$body = eregi_replace("[\]",'',$body);
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->AltBody = $message2; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("$email", "$username");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
print "Your information was sent! Thank-You for registering at AVsBest.com!<br>Please Check your Email at $to to complete registration.";
}
?>
Re: [PHP] Mailer Class help
I use SwiftMailer, works perfect. Also be sure to send a text version AND a HTML version. The mail() function is rather incomplete...
Also, you forgot an ending quote in the mail headers...
Re: [PHP] Mailer Class help
The problems i was facing was incorparting the queries into the mailer
I was trying to base it off the first example - http://phpmailer.codeworxtech.com/index.php?pg=examples
Re: [PHP] Mailer Class help
Hmm.. Yea Daevius helped me find PHPMailer.
Anyway, you did catch this problem:
Quote:
PHP Code:
$to = 'myemail@emaillandirl.com;
it should be $to = 'myemail@emaillandirl.com';
(forget ['])
Re: [PHP] Mailer Class help
thats not a problem it was a mistake i made when i was removing data before i put it on ere - dont want to display my company email address
Re: [PHP] Mailer Class help
Sooo...what's your problem really? You can't get PHPMailer to work or you can't send mails to the Inbox rather then the Spambox with mail()?
Re: [PHP] Mailer Class help
both really - with the script above it doesnt arrive at our works exchange and it goes straight to spam at gmail
and phpmailer just fires loads of errors - i dont have the file i used for phpmailer on my machine though - still on my work machine
Re: [PHP] Mailer Class help
Well I don't know much, but I know that when I used mail() function I had the problem that my emails would arrive in spam, the subject wouldn't show up right (it said CGI-Mailer in subject box), and I could only submit Plain Text. The rest just isn't supported by mail().
I then installed PhpMailer and all I had to do was include the file, copy and past an example/change it, and it worked like a charm!
It appears to me that if you download and install PhpMailer somewhere in your root directory and copy/paste my origonal posted code for sending an email, (replacing my values with your own), it should work. So.. Rip PhpMailer from your work machine and paste it on the desired server and all that. (You know what to do..)
My theory is that if you use mail() alone, it will always arrive in major mail service spam boxes. (AOL, yahoo, msn, etc.)
I hope you don't get the errors again, because I don't get any errors and it works great for me.
Hope this helps! - Spence
Re: [PHP] Mailer Class help
What i want is some advice on how to impliment my code above into a mail class - phpmailer for example so i can test if it will work on my works exchange
Re: [PHP] Mailer Class help
Check out the tutorials provided by PHPMailer, as s-p-n proposed...then integrate your values into it...shouldn't be hard...
Re: [PHP] Mailer Class help
So... you need a script that impliments it into a mail class?
Well once you have PHPMailer, you just include the class.phpmailer.php script and procede to enter in your details. Then at the end just see if the email was sent.
I took your origonal posted code, and put it together with the phpmailer format I use:
PHP Code:
<?
mysql_connect("localhost","devbox","password");
mysql_select_db("devbox") or die( "Unable to select database");
$query=mysql_query("SELECT * FROM `domains` WHERE `exp_date` >= '0000-00-01' ORDER BY exp_date ASC LIMIT 25");
if(mysql_num_rows($query)){
$to = 'myemail@emaillandirl.com';
$subject = "Domain Expiry Notice";
$from = "reminder@domain.co.uk";
$msg = "<font face='MS Sans Serif'>
Hello,</font><BR><BR>";
$msg .= "<font size='2' face='Verdana'>The next 25 domains that are due to expire are:</font><BR><BR>";
while($row=mysql_fetch_array($query))
{
$domain_name=$row["domain_name"];
$company_name=$row["company_name"];
$simply_account=$row["simply_account"];
$notes=$row["notes"];
$id=$row["id"];
$exp_date=$row["exp_date"];
$exp_date = date("d/m/Y", strtotime($exp_date) );
if($query == TRUE)
{
$msg .= "<font size='2' face='Verdana'><b>$company_name</b>: $domain_name - $exp_date </font><BR>";
}
}
$msg .= "<BR>";
$msg .= "<font size='2' face='Verdana>Admin</font><BR><BR>";
$headers = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
$headers .= "From: reminder@domain.co.ukrnReply-To:reminder@domain.co.uk" . "rn";
//Begin s-p-n send code:
include_once('YOUR-PATH-HERE/phpMailer/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = $msg;
$body = eregi_replace("[\]",'',$body);
$mail->From = $from;
$mail->FromName = "YOUR-COMPANY-HERE";
$mail->Subject = $subject;
$mail->AltBody = $msg; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("$to", "$company_name");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
print "Email was sent :-).";
}
//end s-p-n send code
//I commented out your mail script for referrence later and testing now.
//$mailsend = mail("$to","$subject","$msg","$headers");
//echo $mailsend ? "Email was sent :-)." : " Email sending failed :-(.";
}
?>
I hope that's what you needed.. But maybe not unless you're going to use PhpMailer to send your emails.. You'd need to install it for it to actually do anything.. Otherwise you'll get an error or something because your include() would be broken. :) I don't remember if broken includes error or just do nothing
Re: [PHP] Mailer Class help
Ill give it a test now
s-p-n your code sends the email - but it hits my spam box
Re: [PHP] Mailer Class help
It might also be that your IP address is on the black list, list of IP addresses of known spammers (could be someone on that IP, not you probably, that has been spamming in the past)...
Re: [PHP] Mailer Class help
im not the one who sends the mail - its the cron at my host
Re: [PHP] Mailer Class help
Really? lol wow I didn't think it would end up in spam :/
Umm.. Hate to say it, but I don't know :paperbag3
Re: [PHP] Mailer Class help
it works now - its my webhost where the problem lies