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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

As for mail()
[code]
<?php
$to='email@place.com';
$subject='message for you';
$message='message';
$from='From: me@email.com';
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]

Link to comment
Share on other sites

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: me@email.com';
$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
}
?>

Link to comment
Share on other sites

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

 

<?php
$from='From: me@email.com';
$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 <twilitegxa@aol.com\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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.