Jump to content

Anyone know any good mail server to use for Windows?


twilitegxa

Recommended Posts

  • 4 weeks later...

You need a properly configured public mail server in order to get any other mail server to accept emails from your mail server. A public mail server is one that has a domain name associated with it and a DNS server that is configured to resolve DNS requests for the domain and the mail server's DNS records.

If I used this code:

 

mail($recipient, $subject, $mail_body, $header); //mail command 

 

How do I name these varaibles? Do I just do it like this:

 

$subject = "Newsletter #1";

$mail_body = "This is our newsletter...blah blah blah..."

 

How do I pull the $recipients from my table in my database? And what would I put for $header?

There's also mercury mail.  I never figured it out but it's a free option.  

As for mail()
[code]
<?php
$to='[email protected]';
$subject='message for you';
$message='message';
$from='From: [email protected]';
mail($to, $subject, $message, $from);
?>

 

I haven't used it, but cURL has a better solution for mass emails (newsletters etc).  Another option would be using sockets to connect to an smtp server you have access to and sending mail out that way.[/code]

You can only mail to 1 person per mail() if that makes sense.  So if you have 10 people you wish to email, you need to loop it 10 times.

 

<?php
$from='From: [email protected]';
$subject='Subject here';
$message='newsletter';

$emails=mysql_query("SELECT email FROM users");
if(mysql_num_rows($emails)>0){
while($row=mysql_fetch_array($emails)){
	mail($row['email'], $subject, $message, $from);
}
} else{
//No email addresses found
}
?>

I there a way I can use this scriptthat you suggested:

 

<?php
$from='From: [email protected]';
$subject='Subject here';
$message='newsletter';

$emails=mysql_query("SELECT email FROM users");
if(mysql_num_rows($emails)>0){
while($row=mysql_fetch_array($emails)){
	mail($row['email'], $subject, $message, $from);
}
} else{
//No email addresses found
}
?>

 

with my pre-existing code? I have a form that is supposed to take the information I put in and send it to the e-mail addresses in my table from my database, but it doesn't work, apparently because I don't have a mail server on my web server. Here is the script for it below:

 

<?php

//Access Tracking Snippet

//set up static variables
$page_title = "sendmymail.php";
$user_agent = getenv("HTTP_USER_AGENT");
$date_accessed = date("Y-m-d");

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//create and issue query
$sql = "insert into access_tracker values
('', '$page_title', '$user_agent', '$date_accessed')";
mysql_query($sql,$conn);
?>

<?php
if ($_POST[op] != "send") {
//haven't seen the form, so show it
print "
<HTML>
<HEAD>
<TITLE>Send A Newsletter</TITLE>
</HEAD>
<BODY>
<h1>Send A Newsletter</h1>
<form method=\"post\" action=\"$_SERVER[php_SELF]\">
<p><strong>Subject:</strong><br />
<input type=\"text\" name=\"subject\" size=30></p>
<p><strong>Mail Body:</strong><br />
<textarea name=\"message\" cols=50 rows=10 wrap=virtual></textarea>
<input type=\"hidden\" name=\"op\" value=\"send\">
<p><input type=\"submit\" name=\"submit\" value=\"Send It\"></p>
</form>
</body>
</html>";

} else if ($_POST[op] == "send") {
//want to send form; so check for required fields
if (($_POST[subject] =="") || ($_POST[message] == "")) {
header("Location: sendmymail.php");
exit;
}

//connect to database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
mysql_select_db("smrpg",$conn) or doe(mysql_error());

//get emails from subscribers list
$sql = "select email from subscribers";
$result = mysql_query($sql,$conn) or die(mysql_error());

//create a From: mailheader
$headers = "From: Your Mailing List <[email protected]\n";

//loop through results and send mail
while ($row = mysql_fetch_array($result)) {
set_time_limit(0);
$email = $row['email'];
mail("email", stripslashes($_POST[subject]),
stripslashes($_POST[message]), $headers);
print "newsletter sent to $email<br />";
}
}
?>

 

Can someone tell me how I can alter this code to work with the suggested code of using the mail function?

That's what I thought. If anyone knows how I need to configure the php.ini file, please let me know! I think I just need to change the port maybe and the smtp probably. Any help would be greatly appreciated!

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.