www.webdeveloper.com
Results 1 to 5 of 5

Thread: phpmailer getting SPF failed error

  1. #1
    Join Date
    Dec 2008
    Posts
    135

    phpmailer getting SPF failed error

    I am trying to set up a send to friend from that will set the from as the user's email and name. The from address will be what the user fills in the email address field . So everytime for different users, from Email will always be different. So, we need to set the user's email in $mail->From, which is what I do below. The problem is it get rejected in gmail and hotmail. Is there a work around to make this work?

    Code:
                   $mail = new PHPMailer();
    		$mail->IsSMTP();
    		$mail->SMTPAuth   = true;
    		$mail->SMTPSecure = 'ssl';
    		$mail->Host       = 'domain.com';
    		$mail->Port       = 465; 
    		$mail->Username   = 'smtp@domain.com';
    		$mail->Password   = 'password';
    		$mail->SetFrom($useremail, $firstname . " " . $lastname);
    		$mail->AddReplyTo($useremail, $firstname . " " . $lastname);
    		$mail->Subject  = $subject;
    		$mail->MsgHTML($message);
    		$mail->AddAddress($toemail);

  2. #2
    Join Date
    Mar 2012
    Posts
    1,639
    I'm not sure, but perhaps:
    Code:
    		$mail->SetFrom($useremail, $firstname . " " . $lastname);
    		$mail->AddReplyTo($useremail, $firstname . " " . $lastname);
    should be:
    Code:
    		$mail->SetFrom($useremail . ', ' . $firstname . ' ' . $lastname);
    		$mail->AddReplyTo($useremail . ', ' . $firstname . ' ' . $lastname);
    ? Just a thought...

  3. #3
    Join Date
    Mar 2012
    Posts
    1,639
    On second thoughts, does the following work (without from name and reply to)?:

    Code:
    $mail->From=$useremail;

  4. #4
    Join Date
    Dec 2008
    Posts
    135
    I just tried both your script but still the same (I think gmail and hotmail is blocking it because the FROM is not my domain email). I have tried to use an email from my domain for the FROM and it works. I just want to have a work around to make it allow other email such as gmail or hotmail to be set as FROM.

  5. #5
    Join Date
    Mar 2012
    Posts
    1,639
    That may not be possible, because it is assumed to be spam, so is blocked. Can you set From to an email from your domain, and AddReplyTo to $useremail?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles