SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Some question about Pear Mail

    I get a Pear message of, "Validation failed for: My-Example.com" when $from = "My-Example.com <support@my-example.com>". However, I don't get an error if I change $from to "Example <support@my-example.com>" Why would having a hypen and a .com as part of the FROM address cause validation errors?

    Also, is this the most efficient way to send out 500 emails or more at one time? I don't know tons about SMTP, but I assume it is authenticating with the SMTP server for every single email that is being sent out with my DO WHILE loop.

    Thoughts?

    PHP Code:
    $from "My-Example.com <support@my-example.com>";
    $host "mail.my-example.com";
    $username "support@my-example.com";
    $password "******";

    $headers = array (
    'To' => $recipient,
    'From' => $from,
    'Subject' => $subject,
    'Reply-To' => $sender,
    'Errors-To' => $sender);

    $smtp Mail::factory('smtp', array (
    'host' => $host,
    'auth' => true,
     
    'username' => $username,
    'password' => $password));

    $mail $smtp->send($recipient$headers$body);

    if (
    PEAR::isError($mail)) {
    echo(
    "<p>" $mail->getMessage() . "</p>");
    } else {
    $success "Yes";
    //Code for updating the DB table so the email doesn't get resent.

    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello? Still looking for some help.
    Convert your dollars into silver coins. www.convert2silver.com

  3. #3
    SitePoint Member drziegler's Avatar
    Join Date
    Jun 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got the same questions, although the question about repeated SMTP authentication is more or less elementary for me at the moment. The primary question, however, is immediate. I'm trying to send mail from "Daniel R. Ziegler <email@redacted.com>" and get "Validation failed for: Daniel R. Ziegler <email@redacted.com>". Can anyone help sort this out? Is there a work-around or do I need to strip certain characters from the name?

  4. #4
    SitePoint Member drziegler's Avatar
    Join Date
    Jun 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A few hours later here and a solution. Change line 1 of your script to the following:

    Code:
    $from = "\"My-Example.com\" <support@my-example.com>";
    And, for me at least, problem solved. This question must not come up frequently because it took a bit of digging to unearth it. Either everyone else using PEAR's SMTP is a better programmer than I (likely) or it's simply not a common usage.

    Anyway, hopefully useful for someone in the future as this thread is the third or fourth result on Google for my initial search.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •