Skip to content

Commit

Permalink
Merge pull request PHPMailer#502 from fbonzon/master
Browse files Browse the repository at this point in the history
In examples, prefer setFrom() over separate From and FromName
  • Loading branch information
Synchro committed Sep 17, 2015
2 parents 76619dd + e1964dd commit b192b45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -82,8 +82,7 @@ $mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to

$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
Expand Down
7 changes: 3 additions & 4 deletions docs/extending.html
Expand Up @@ -18,10 +18,9 @@ <h3>1. Advanced Example</h3>

$mail = new PHPMailer();

$mail->From = 'list@example.com';
$mail->FromName = 'List manager';
$mail->Host = 'smtp1.example.com;smtp2.example.com';
$mail->Mailer = 'smtp';
$mail->setFrom('list@example.com', 'List manager');
$mail->Host = 'smtp1.example.com;smtp2.example.com';
$mail->Mailer = 'smtp';

@mysqli_connect('localhost','root','password');
@mysqli_select_db("my_company");
Expand Down
20 changes: 10 additions & 10 deletions examples/code_generator.phps
Expand Up @@ -45,9 +45,11 @@ $example_code .= "\n\n\$results_messages = array();";

$mail = new PHPMailer(true); //PHPMailer instance with exceptions enabled
$mail->CharSet = 'utf-8';
ini_set('default_charset', 'UTF-8');
$mail->Debugoutput = $CFG['smtp_debugoutput'];
$example_code .= "\n\n\$mail = new PHPMailer(true);";
$example_code .= "\n\$mail->CharSet = 'utf-8';";
$example_code .= "\nini_set('default_charset', 'UTF-8');";

class phpmailerAppException extends phpmailerException
{
Expand Down Expand Up @@ -117,21 +119,19 @@ try {
try {
if ($_POST['From_Name'] != '') {
$mail->addReplyTo($_POST['From_Email'], $_POST['From_Name']);
$mail->From = $_POST['From_Email'];
$mail->FromName = $_POST['From_Name'];
$mail->setFrom($_POST['From_Email'], $_POST['From_Name']);

$example_code .= "\n\$mail->addReplyTo(\"" .
$_POST['From_Email'] . "\", \"" . $_POST['From_Name'] . "\");";
$example_code .= "\n\$mail->From = \"" . $_POST['From_Email'] . "\";";
$example_code .= "\n\$mail->FromName = \"" . $_POST['From_Name'] . "\";";
$example_code .= "\n\$mail->setFrom(\"" .
$_POST['From_Email'] . "\", \"" . $_POST['From_Name'] . "\");";
} else {
$mail->addReplyTo($_POST['From_Email']);
$mail->From = $_POST['From_Email'];
$mail->FromName = $_POST['From_Email'];
$mail->setFrom($_POST['From_Email'], $_POST['From_Email']);

$example_code .= "\n\$mail->addReplyTo(\"" . $_POST['From_Email'] . "\");";
$example_code .= "\n\$mail->From = \"" . $_POST['From_Email'] . "\";";
$example_code .= "\n\$mail->FromName = \"" . $_POST['From_Email'] . "\";";
$example_code .= "\n\$mail->setFrom(\"" .
$_POST['From_Email'] . "\", \"" . $_POST['From_Email'] . "\");";
}

if ($_POST['To_Name'] != '') {
Expand Down Expand Up @@ -162,7 +162,7 @@ try {
}
$mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')';
$example_code .= "\n\$mail->Subject = \"" . $_POST['Subject'] .
'(PHPMailer test using ' . strtoupper($_POST['test_type']) . ')";';
' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')";';

if ($_POST['Message'] == '') {
$body = file_get_contents('contents.html');
Expand Down Expand Up @@ -594,4 +594,4 @@ if (isset($_POST["submit"]) && $_POST["submit"] == "Submit") {
</div>
</form>
</body>
</html>
</html>

0 comments on commit b192b45

Please sign in to comment.