send email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
roice
Forum Commoner
Posts: 35
Joined: Tue Mar 02, 2010 9:14 am

send email

Post by roice »

Hello,

strange thing with my email code - I tried to send an email with form but sometime its successed and sometime it's not
if I change the TO filed it works (sometimes).
I thought that maybe GOOGLE block the server adress so I upload the same code to another server, but same thing happened...

here is the code:

Code: Select all

				$message = "";
				$subject = "email from website";
				$date  = mktime(date("H"), date("i"), date("s"), date("m")  , date("d"), date("Y"));
				$date = date("d.m.Y", $date);
				$siteName = "my-website.com";
				$from = "MIME-Version: 1.0 \r\n";
				$from .= "From: $site_email \r\n";
				$site_email = "some-email@gmail.com‏";
				$message = " 
				$date 
				Site name $siteName
				name: $name
				phone: $phone
				email: $email
				text: $text
				";
				
				if (mail($site_email, $subject, $message, $from)); 			
					echo "<div class='msg msg_approve'>success</div>";

I tried to send the email to number of emails address but it did worked...
What do I do wrong?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: send email

Post by requinix »

Email is more complicated nowadays then simply about sending something from one person to another. I strongly suggest you use a library like SwiftMailer or PHPMailer. Both of them are more knowledgeable about how to send proper emails that are much less likely to be rejected by spam filters.
roice
Forum Commoner
Posts: 35
Joined: Tue Mar 02, 2010 9:14 am

Re: send email

Post by roice »

do you have some code for example that use SwiftMailer or PHPMailer?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: send email

Post by requinix »

Not myself no, but Google does.
Post Reply